package main import ( "io/ioutil" "os" "testing" "github.com/stretchr/testify/assert" ) func runImageTest(content string) error { poshImagePath := "ohmyposh.png" file, err := ioutil.TempFile("", poshImagePath) if err != nil { return err } defer os.Remove(file.Name()) ansi := &ansiUtils{} ansi.init(plain) image := &ImageRenderer{ ansiString: content, ansi: ansi, } image.init() err = image.SavePNG(poshImagePath) return err } func TestStringImageFileWithText(t *testing.T) { err := runImageTest("foobar") assert.NoError(t, err) } func TestStringImageFileWithANSI(t *testing.T) { prompt := ` oh-my-posh  main ≡  ~4 -8 ?7   ` err := runImageTest(prompt) assert.NoError(t, err) }