fix(acceptance): 使用可完整解码的 WebP 样本

替换截断的 WebP 验收夹具,新增全量图片像素解码回归,并保留 6K 外部水化与三参考图归一化测试,避免协议模拟样本缺陷被误判为 Worker 运行故障。\n\n验证:Go 全量测试、go vet、gofmt、git diff --check 通过。
This commit is contained in:
2026-07-31 21:11:50 +08:00
parent 29533537ec
commit 29a9b8c89f
3 changed files with 77 additions and 5 deletions
@@ -8,6 +8,7 @@ import (
"image/color"
"image/jpeg"
"image/png"
"os"
"strings"
"testing"
"time"
@@ -147,6 +148,50 @@ func TestImageNormalizationSlotSerializesHeavyConversions(t *testing.T) {
}
}
func TestHydrateAndNormalizeExternalSixKReference(t *testing.T) {
fixtureURL := strings.TrimSpace(os.Getenv("AI_GATEWAY_TEST_VIDEO_FIXTURE_URL"))
if fixtureURL == "" {
t.Skip("set AI_GATEWAY_TEST_VIDEO_FIXTURE_URL to exercise a protocol fixture over HTTP")
}
service := &Service{imageNormalizeSlots: make(chan struct{}, 1)}
candidate := store.RuntimeModelCandidate{
Provider: "volces",
PlatformConfig: map[string]any{"supportUrlInput": true, "supportBase64Input": true},
ModelType: "omni_video",
Capabilities: map[string]any{
"omni_video": map[string]any{
"input_image_resolution_range": map[string]any{
"min": map[string]any{"long_edge": float64(300), "short_edge": float64(300)},
"max": map[string]any{"long_edge": float64(6000), "short_edge": float64(6000)},
},
"input_image_aspect_ratio_range": []any{float64(0.4), float64(2.5)},
},
},
}
content := make([]any, 0, 3)
for range 3 {
content = append(content, map[string]any{
"type": "image_url", "role": "reference_image",
"image_url": map[string]any{"url": fixtureURL},
})
}
body := map[string]any{"content": content}
hydrated, err := service.hydrateProviderRequestAssets(context.Background(), body, candidate)
if err != nil {
t.Fatal(err)
}
normalized, err := service.normalizeVideoInputImages(context.Background(), hydrated, candidate)
if err != nil {
t.Fatal(err)
}
for index, item := range normalized["content"].([]any) {
imageURL := item.(map[string]any)["image_url"].(map[string]any)["url"].(string)
if got := decodedImageSize(t, imageURL); got != image.Pt(6000, 2400) {
t.Fatalf("image %d has unexpected converted size: %v", index, got)
}
}
}
func TestNormalizeVideoInputImagesPadsAspectRatioViolation(t *testing.T) {
service := &Service{}
source := pngImageDataURL(t, 1530, 500)