Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
47 lines
968 B
Go
47 lines
968 B
Go
package xgenny_test
|
|
|
|
import (
|
|
"io"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/gobuffalo/genny/v2"
|
|
"github.com/gobuffalo/plush/v4"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/ignite/cli/v29/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))
|
|
}
|