fix(acceptance): 使用可完整解码的 WebP 样本
替换截断的 WebP 验收夹具,新增全量图片像素解码回归,并保留 6K 外部水化与三参考图归一化测试,避免协议模拟样本缺陷被误判为 Worker 运行故障。\n\n验证:Go 全量测试、go vet、gofmt、git diff --check 通过。
This commit is contained in:
@@ -62,11 +62,18 @@ func TestGeminiAndVolcesProtocolEmulation(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("get oversized fixture: %v", err)
|
||||
}
|
||||
config, format, err := image.DecodeConfig(fixtureResponse.Body)
|
||||
fixturePayload, readErr := io.ReadAll(fixtureResponse.Body)
|
||||
_ = fixtureResponse.Body.Close()
|
||||
if readErr != nil {
|
||||
t.Fatalf("read oversized fixture: %v", readErr)
|
||||
}
|
||||
config, format, err := image.DecodeConfig(bytes.NewReader(fixturePayload))
|
||||
if err != nil || format != "jpeg" || config.Width != 6144 || config.Height != 2160 {
|
||||
t.Fatalf("oversized fixture format=%s config=%+v err=%v", format, config, err)
|
||||
}
|
||||
if _, format, err = image.Decode(bytes.NewReader(fixturePayload)); err != nil || format != "jpeg" {
|
||||
t.Fatalf("fully decode oversized fixture format=%s err=%v", format, err)
|
||||
}
|
||||
|
||||
content := []any{map[string]any{"type": "text", "text": "video"}}
|
||||
for index, name := range []string{"image-00.png", "image-04.jpg", "image-08.webp"} {
|
||||
@@ -148,6 +155,22 @@ func TestForcedConversionRejectsImagesOutsideOfficialSeedanceRange(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageFixturesFullyDecode(t *testing.T) {
|
||||
for name, fixture := range buildFixtures() {
|
||||
if !strings.HasPrefix(fixture.ContentType, "image/") {
|
||||
continue
|
||||
}
|
||||
decoded, format, err := image.Decode(bytes.NewReader(fixture.Payload))
|
||||
if err != nil {
|
||||
t.Fatalf("fixture %s does not fully decode: %v", name, err)
|
||||
}
|
||||
bounds := decoded.Bounds()
|
||||
if format == "" || bounds.Dx() <= 0 || bounds.Dy() <= 0 {
|
||||
t.Fatalf("fixture %s format=%q bounds=%v", name, format, bounds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPaddedPNGIsValidAndExact(t *testing.T) {
|
||||
for _, size := range []int{256 << 10, 4 << 20, 8 << 20} {
|
||||
payload := paddedPNG(size)
|
||||
|
||||
Reference in New Issue
Block a user