github.com/Finschia/ostracon@v1.1.5/test/e2e/generator/main_test.go (about)

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