diff --git a/libs/log/lazy_test.go b/libs/log/lazy_test.go new file mode 100644 index 000000000..296280b72 --- /dev/null +++ b/libs/log/lazy_test.go @@ -0,0 +1,29 @@ +package log + +import ( + tmbytes "github.com/line/ostracon/libs/bytes" + "github.com/stretchr/testify/require" + "testing" +) + +func TestNewLazySprintf(t *testing.T) { + format := "echo:%s" + args := make([]interface{}, 0, 1) + args = append(args, "hello") + expected := LazySprintf{format: format, args: args} + actual := NewLazySprintf(format, args...) + require.Equal(t, expected.String(), actual.String()) +} + +func TestNewLazyBlockHash(t *testing.T) { + block := testHashable{} + expected := LazyBlockHash{block: block} + actual := NewLazyBlockHash(block) + require.Equal(t, expected.String(), actual.String()) +} + +type testHashable struct{} + +func (testHashable) Hash() tmbytes.HexBytes { + return []byte{0} +} diff --git a/test/e2e/generator/generate_test.go b/test/e2e/generator/generate_test.go new file mode 100644 index 000000000..b87e1dcfe --- /dev/null +++ b/test/e2e/generator/generate_test.go @@ -0,0 +1,30 @@ +package main + +import ( + "github.com/stretchr/testify/require" + "math/rand" + "testing" +) + +func TestGenerate(t *testing.T) { + testcases := []struct { + name string + version string + }{ + { + name: "empty version", + version: "", + }, + { + name: "specify version", + version: "2", + }, + } + for _, tc := range testcases { + t.Run(tc.name, func(t *testing.T) { + manifests, err := Generate(rand.New(rand.NewSource(randomSeed)), tc.version) + require.NoError(t, err) + require.NotNil(t, manifests) + }) + } +} diff --git a/test/e2e/generator/main_test.go b/test/e2e/generator/main_test.go new file mode 100644 index 000000000..c645c2af0 --- /dev/null +++ b/test/e2e/generator/main_test.go @@ -0,0 +1,52 @@ +package main + +import ( + "github.com/stretchr/testify/require" + "io/ioutil" + "os" + "testing" +) + +func TestNewCLI(t *testing.T) { + tempDir, err := ioutil.TempDir("", "runner") + require.NoError(t, err) + defer os.RemoveAll(tempDir) //nolint:staticcheck + cmd := NewCLI() + testcases := []struct { + name string + wantErr bool + args []string + }{ + { + name: "default", + wantErr: true, + args: []string{ + "-d", tempDir, + }, + }, + { + name: "specify groups", + wantErr: true, + args: []string{ + "-d", tempDir, + "-g", "1", + }, + }, + { + name: "specify version", + wantErr: true, + args: []string{ + "-d", tempDir, + "-m", "1", + }, + }, + } + + for _, tc := range testcases { + t.Run(tc.name, func(t *testing.T) { + err := cmd.root.ParseFlags(tc.args) + require.NoError(t, err) + cmd.Run() + }) + } +}