Path: blob/main/integration/cosmosgen/cosmosgen_composables_test.go
1007 views
package cosmosgen_test12import (3"os"4"path/filepath"5"testing"67"github.com/stretchr/testify/assert"8"github.com/stretchr/testify/require"910envtest "github.com/ignite/cli/v29/integration"11)1213func TestCosmosGenScaffoldComposables(t *testing.T) {14if envtest.IsCI {15t.Skip("Skipping TestCosmosGenScaffoldComposables test in CI environment")16}1718var (19env = envtest.New(t)20app = env.ScaffoldApp("github.com/test/blog")21)2223const (24withMsgModuleName = "withmsg"25withoutMsgModuleName = "withoutmsg"26)2728app.Scaffold("add custom module with message", false, "module", withMsgModuleName)2930app.Scaffold(31"create a message",32false,33"message",34"mymessage",35"myfield1",36"myfield2:bool",37"--module",38withMsgModuleName,39)4041app.Scaffold(42"add custom module without message",43false,44"module",45withoutMsgModuleName,46)4748app.Scaffold(49"create a type",50false,51"type",52"mytype",53"mytypefield",54"--module",55withoutMsgModuleName,56)5758app.Scaffold(59"create a query",60false,61"query",62"myQuery",63"mytypefield",64"--module",65withoutMsgModuleName,66)6768composablesDirGenerated := filepath.Join(app.SourcePath(), "vue/src/composables")69require.NoError(t, os.RemoveAll(composablesDirGenerated))7071app.Scaffold(72"scaffold vue",73false,74"vue",75)7677app.Generate(78"generate composables",79false,80"composables",81"--clear-cache",82)8384expectedQueryModules := []string{85"useCosmosAuthV1Beta1",86"useCosmosAuthzV1Beta1",87"useCosmosBankV1Beta1",88"useCosmosBaseTendermintV1Beta1",89"useCosmosDistributionV1Beta1",90"useCosmosEvidenceV1Beta1",91"useCosmosFeegrantV1Beta1",92"useCosmosGovV1Beta1",93"useCosmosGovV1",94"useCosmosGroupV1",95"useCosmosMintV1Beta1",96"useCosmosNftV1Beta1",97"useCosmosParamsV1Beta1",98"useCosmosSlashingV1Beta1",99"useCosmosStakingV1Beta1",100"useCosmosTxV1Beta1",101"useCosmosUpgradeV1Beta1",102"useCosmosVestingV1Beta1",103// custom modules104"useBlogBlogV1",105"useBlogWithmsgV1",106"useBlogWithoutmsgV1",107}108109for _, mod := range expectedQueryModules {110_, err := os.Stat(filepath.Join(composablesDirGenerated, mod))111if assert.False(t, os.IsNotExist(err), "missing composable %q in %s", mod, composablesDirGenerated) {112assert.NoError(t, err)113}114}115116if t.Failed() {117// list composables files118composablesFiles, err := os.ReadDir(composablesDirGenerated)119require.NoError(t, err)120t.Log("Composables files:", len(composablesFiles))121for _, file := range composablesFiles {122t.Logf(" - %s", file.Name())123}124}125}126127128