31 lines
739 B
Go
31 lines
739 B
Go
//go:build export_samples
|
|
|
|
package caption_test
|
|
|
|
import (
|
|
"image"
|
|
"image/png"
|
|
"os"
|
|
"path"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func init() {
|
|
beforeCheck = append(beforeCheck, func(t *testing.T, name string, got image.Image) {
|
|
t.Run("export", func(t *testing.T) {
|
|
outPath := strings.TrimSpace(os.Getenv("TEST_RENDER_OUT_PATH"))
|
|
if len(outPath) == 0 {
|
|
outPath = os.TempDir()
|
|
}
|
|
outPath = path.Join(outPath, "overlay-"+name+".png")
|
|
if re, err := os.Create(outPath); err != nil {
|
|
t.Fatalf("cannot create: %v", err)
|
|
} else if err = (&png.Encoder{CompressionLevel: png.NoCompression}).Encode(re, got); err != nil {
|
|
t.Fatalf("cannot encode to file: %v", err)
|
|
}
|
|
t.Logf("test case exported to %s", outPath)
|
|
})
|
|
})
|
|
}
|