mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
fix: enable grok media generation groups
This commit is contained in:
@@ -146,6 +146,25 @@ func TestBuildGrokResponsesRequestRejectsUnsafeAccountBaseURL(t *testing.T) {
|
||||
require.Contains(t, err.Error(), "invalid base url")
|
||||
}
|
||||
|
||||
func TestGrokMediaGenerationGateCoversImagesAndVideo(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
endpoint GrokMediaEndpoint
|
||||
want bool
|
||||
}{
|
||||
{name: "image generation", endpoint: GrokMediaEndpointImagesGenerations, want: true},
|
||||
{name: "image edit", endpoint: GrokMediaEndpointImagesEdits, want: true},
|
||||
{name: "video generation", endpoint: GrokMediaEndpointVideosGenerations, want: true},
|
||||
{name: "video status", endpoint: GrokMediaEndpointVideoStatus, want: false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
require.Equal(t, tt.want, tt.endpoint.IsGenerationRequest())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractGrokMediaModelSupportsJSONAndMultipart(t *testing.T) {
|
||||
require.Equal(t, "grok-imagine", ExtractGrokMediaModel("application/json", []byte(`{"model":"grok-imagine"}`)))
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
-- PR 3593 added Grok media routes for image generation, image edits, and video generation.
|
||||
-- Existing Grok groups were created before the image-generation gate knew about
|
||||
-- the Grok platform, so backfill them onto the same generation capability gate.
|
||||
UPDATE groups
|
||||
SET allow_image_generation = true
|
||||
WHERE platform = 'grok'
|
||||
AND allow_image_generation = false;
|
||||
@@ -169,6 +169,17 @@ func TestMigration151AddsAccountAutoPauseExpiryPartialIndex(t *testing.T) {
|
||||
require.Contains(t, sql, "expires_at IS NOT NULL")
|
||||
}
|
||||
|
||||
func TestMigration158BackfillsGrokMediaGenerationGroups(t *testing.T) {
|
||||
content, err := FS.ReadFile("158_enable_grok_media_generation_groups.sql")
|
||||
require.NoError(t, err)
|
||||
|
||||
sql := string(content)
|
||||
require.Contains(t, sql, "UPDATE groups")
|
||||
require.Contains(t, sql, "SET allow_image_generation = true")
|
||||
require.Contains(t, sql, "WHERE platform = 'grok'")
|
||||
require.Contains(t, sql, "AND allow_image_generation = false")
|
||||
}
|
||||
|
||||
func TestMigration154AddsSparkShadowColumnsAndConstraintsWithoutHotIndexes(t *testing.T) {
|
||||
content, err := FS.ReadFile("154_account_spark_shadow.sql")
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user