forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_test.go
54 lines (44 loc) · 1.31 KB
/
start_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"bytes"
"context"
"os"
"path/filepath"
"strings"
"testing"
"github.com/gnolang/gno/tm2/pkg/commands"
"github.com/stretchr/testify/require"
)
func TestStartInitialize(t *testing.T) {
t.Parallel()
cases := []struct {
args []string
}{
{[]string{"start", "--skip-start", "--skip-failing-genesis-txs"}},
// {[]string{"--skip-start"}},
// FIXME: test seems flappy as soon as we have multiple cases.
}
os.Chdir(filepath.Join("..", "..")) // go to repo's root dir
for _, tc := range cases {
tc := tc
name := strings.Join(tc.args, " ")
t.Run(name, func(t *testing.T) {
t.Parallel()
mockOut := bytes.NewBufferString("")
mockErr := bytes.NewBufferString("")
io := commands.NewTestIO()
io.SetOut(commands.WriteNopCloser(mockOut))
io.SetErr(commands.WriteNopCloser(mockErr))
cmd := newRootCmd(io)
t.Logf(`Running "gnoland %s"`, strings.Join(tc.args, " "))
err := cmd.ParseAndRun(context.Background(), tc.args)
require.NoError(t, err)
stdout := mockOut.String()
stderr := mockErr.String()
require.Contains(t, stderr, "Node created.", "failed to create node")
require.Contains(t, stderr, "'--skip-start' is set. Exiting.", "not exited with skip-start")
require.NotContains(t, stdout, "panic:")
})
}
}
// TODO: test various configuration files?