mukan-ignite/ignite/pkg/xgenny/transformer_test.go
Mukan Erkin Törük c32551b6f7
Some checks failed
Docs Deploy / build_and_deploy (push) Has been cancelled
Generate Docs / cli (push) Has been cancelled
Generate Config Doc / cli (push) Has been cancelled
Go formatting / go-formatting (push) Has been cancelled
Check links / markdown-link-check (push) Has been cancelled
Integration / pre-test (push) Has been cancelled
Integration / test on (push) Has been cancelled
Integration / status (push) Has been cancelled
Lint / Lint Go code (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
refactor: replace all github.com upstream refs with git.cw.tr/mukan-network
2026-05-11 03:36:24 +03:00

47 lines
979 B
Go

package xgenny_test
import (
"io"
"strings"
"testing"
"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/plush/v4"
"github.com/stretchr/testify/require"
"git.cw.tr/mukan-network/mukan-ignite/ignite/pkg/xgenny"
)
func Test_Transformer(t *testing.T) {
r := require.New(t)
ctx := plush.NewContext()
ctx.Set("name", "mark")
f := genny.NewFile("foo.plush.txt", strings.NewReader("Hello <%= name %>"))
tr := xgenny.Transformer(ctx)
f, err := tr.Transform(f)
r.NoError(err)
r.Equal("foo.txt", f.Name())
b, err := io.ReadAll(f)
r.NoError(err)
r.Equal("Hello mark", string(b))
}
func Test_Transformer_No_Ext(t *testing.T) {
r := require.New(t)
ctx := plush.NewContext()
ctx.Set("name", "mark")
f := genny.NewFile("foo.txt", strings.NewReader("Hello <%= name %>"))
tr := xgenny.Transformer(ctx)
f, err := tr.Transform(f)
r.NoError(err)
r.Equal("foo.txt", f.Name())
b, err := io.ReadAll(f)
r.NoError(err)
r.Equal("Hello <%= name %>", string(b))
}