mukan-ignite/ignite/templates/app/proto_test.go
Mukan Erkin Törük 26b204bd04
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
feat: fork Ignite CLI v29 as Mukan Ignite — remove cosmos-sdk restrictions
2026-05-11 03:31:37 +03:00

58 lines
1.1 KiB
Go

package app
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestBufFiles(t *testing.T) {
want := []string{"buf.lock", "buf.yaml"}
protoDir, err := os.ReadDir("files/{{protoDir}}")
require.NoError(t, err)
for _, e := range protoDir {
want = append(want, filepath.Join("{{protoDir}}", strings.TrimSuffix(e.Name(), ".plush")))
}
got, err := BufFiles()
require.NoError(t, err)
require.ElementsMatch(t, want, got)
}
func TestCutTemplatePrefix(t *testing.T) {
tests := []struct {
name string
arg string
want string
ok bool
}{
{
name: "with prefix",
arg: "{{protoDir}}/myvalue",
want: "myvalue",
ok: true,
},
{
name: "with 2 prefix",
arg: "{{protoDir}}/{{protoDir}}/myvalue",
want: "{{protoDir}}/myvalue",
ok: true,
},
{
name: "without prefix",
arg: "myvalue",
want: "myvalue",
ok: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, ok := CutTemplatePrefix(tt.arg)
require.Equal(t, tt.ok, ok)
require.Equal(t, tt.want, got)
})
}
}