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
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package cosmosgen
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/ignite/cli/v29/ignite/pkg/cosmosanalysis/module"
|
|
"github.com/ignite/cli/v29/ignite/pkg/protoanalysis"
|
|
)
|
|
|
|
func TestTypescriptModulePath(t *testing.T) {
|
|
modulePath := TypescriptModulePath("prefix")
|
|
|
|
cases := []struct {
|
|
name string
|
|
goModulePath string
|
|
protoPkgName string
|
|
want string
|
|
}{
|
|
{
|
|
name: "github uri",
|
|
goModulePath: "github.com/owner/app",
|
|
protoPkgName: "owner.app.module",
|
|
want: "prefix/owner.app.module",
|
|
},
|
|
{
|
|
name: "short uri",
|
|
goModulePath: "domain.com/app",
|
|
protoPkgName: "app.module",
|
|
want: "prefix/app.module",
|
|
},
|
|
{
|
|
name: "path",
|
|
goModulePath: "owner/app",
|
|
protoPkgName: "owner.app.module",
|
|
want: "prefix/owner.app.module",
|
|
},
|
|
{
|
|
name: "name",
|
|
goModulePath: "app",
|
|
protoPkgName: "app.module",
|
|
want: "prefix/app.module",
|
|
},
|
|
}
|
|
|
|
for _, tt := range cases {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
m := module.Module{
|
|
GoModulePath: tt.goModulePath,
|
|
Pkg: protoanalysis.Package{
|
|
Name: tt.protoPkgName,
|
|
},
|
|
}
|
|
|
|
require.Equal(t, tt.want, modulePath(m))
|
|
})
|
|
}
|
|
}
|