package handler import ( "bytes" "context" "image" "image/color" "image/png" "strings" "testing" "github.com/google/uuid" "github.com/warmbly/warmbly/internal/infrastructure/storage" ) func pngBytes(t *testing.T, w, h int) []byte { t.Helper() img := image.NewRGBA(image.Rect(0, 0, w, h)) img.Set(1, 1, color.RGBA{R: 200, A: 255}) var buf bytes.Buffer if err := png.Encode(&buf, img); err != nil { t.Fatal(err) } return buf.Bytes() } func TestReencodeLogoDropsTrailingBytes(t *testing.T) { src := append(pngBytes(t, 64, 64), []byte("")...) out, mime, ext, xerr := reencodeLogo(src) if xerr != nil { t.Fatalf("reencode: %v", xerr) } if mime != "image/png" || ext != ".png" { t.Fatalf("mime %q ext %q", mime, ext) } if bytes.Contains(out, []byte("