github.com/line/ostracon@v1.0.10-0.20230328032236-7f20145f065d/test/e2e/generator/main_test.go (about) 1 package main 2 3 import ( 4 "github.com/stretchr/testify/require" 5 "io/ioutil" 6 "os" 7 "testing" 8 ) 9 10 func TestNewCLI(t *testing.T) { 11 tempDir, err := ioutil.TempDir("", "generator") 12 require.NoError(t, err) 13 defer os.RemoveAll(tempDir) //nolint:staticcheck 14 cmd := NewCLI() 15 testcases := []struct { 16 name string 17 wantErr bool 18 args []string 19 }{ 20 { 21 name: "default", 22 wantErr: true, 23 args: []string{ 24 "-d", tempDir, 25 }, 26 }, 27 { 28 name: "specify groups", 29 wantErr: true, 30 args: []string{ 31 "-d", tempDir, 32 "-g", "1", 33 }, 34 }, 35 { 36 name: "specify version", 37 wantErr: true, 38 args: []string{ 39 "-d", tempDir, 40 "-m", "1", 41 }, 42 }, 43 } 44 45 for _, tc := range testcases { 46 t.Run(tc.name, func(t *testing.T) { 47 err := cmd.root.ParseFlags(tc.args) 48 require.NoError(t, err) 49 cmd.Run() 50 }) 51 } 52 }