emdbed/emdbed_test.go

30 lines
589 B
Go

package emdbed
import (
"embed"
"strings"
"testing"
"github.com/matryer/is"
)
//go:embed testdata
var testdata embed.FS
func TestIdempotent(t *testing.T) {
assert := is.NewRelaxed(t)
fi, err := testdata.Open("testdata/main.md")
defer fi.Close()
out, err := Convert("testdata", fi)
assert.NoErr(err) // Conversion should be successful
idem := out
for idx := 0; idx < 100; idx++ {
idem, err = Convert("testdata", strings.NewReader(idem))
assert.NoErr(err) // Conversion should be successful
}
assert.Equal(out, idem) // Original output should match after 100 tries
}