-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathapp_test.go
More file actions
121 lines (106 loc) · 2.81 KB
/
app_test.go
File metadata and controls
121 lines (106 loc) · 2.81 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package integration_test
import (
"bytes"
"os"
"path"
"path/filepath"
"strings"
"testing"
pluginsconfig "github.com/ignite/cli/v29/ignite/config/plugins"
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step"
"github.com/ignite/cli/v29/ignite/pkg/goenv"
"github.com/ignite/cli/v29/ignite/services/plugin"
envtest "github.com/ignite/cli/v29/integration"
"github.com/stretchr/testify/require"
)
func TestEvolve(t *testing.T) {
var (
require = require.New(t)
env = envtest.New(t)
app = env.ScaffoldApp("github.com/apps/evolve")
)
dir, err := os.Getwd()
require.NoError(err)
pluginPath := filepath.Join(filepath.Dir(filepath.Dir(dir)), "evolve")
env.Must(env.Exec("install evolve app locally",
step.NewSteps(step.New(
step.Exec(envtest.IgniteApp, "app", "install", pluginPath),
step.Workdir(app.SourcePath()),
)),
))
// One local plugin expected
assertLocalPlugins(t, app, []pluginsconfig.Plugin{{Path: pluginPath}})
assertGlobalPlugins(t, nil)
env.Must(env.Exec("run evolve add",
step.NewSteps(step.New(
step.Exec(
envtest.IgniteApp,
"evolve",
"add",
),
step.Workdir(app.SourcePath()),
)),
))
env.Must(env.Exec("run evolve add-migrate",
step.NewSteps(step.New(
step.Exec(
envtest.IgniteApp,
"evolve",
"add-migrate",
),
step.Workdir(app.SourcePath()),
)),
))
buf := &bytes.Buffer{}
bin := path.Join(goenv.Bin(), app.Binary())
env.Must(env.Exec("check evolved", step.NewSteps(
step.New(
step.Exec(
envtest.IgniteApp,
"chain",
"build",
),
step.Workdir(app.SourcePath()),
),
step.New(
step.Exec(bin, "start", "--help"),
step.Stdout(buf),
step.Workdir(app.SourcePath()),
)),
))
if !strings.Contains(buf.String(), "--evnode.da") {
t.Errorf("evolved doesn't contain --evnode flags: %s", buf.String())
}
buf.Reset()
env.Must(env.Exec("run evolve init", step.NewSteps(
step.New(
step.Exec(
envtest.IgniteApp,
"evolve",
"init",
),
step.PostExec(func(exitErr error) error {
return os.Remove(bin)
}),
step.Workdir(app.SourcePath()),
step.Stdout(buf),
),
)))
if !strings.Contains(buf.String(), "Initialized. Checkout your evolve chain's home") {
t.Errorf("ignite evolve init has failed: %s", buf.String())
}
}
func assertLocalPlugins(t *testing.T, app envtest.App, expectedPlugins []pluginsconfig.Plugin) {
t.Helper()
cfg, err := pluginsconfig.ParseDir(app.SourcePath())
require.NoError(t, err)
require.ElementsMatch(t, expectedPlugins, cfg.Apps, "unexpected local apps")
}
func assertGlobalPlugins(t *testing.T, expectedPlugins []pluginsconfig.Plugin) {
t.Helper()
cfgPath, err := plugin.PluginsPath()
require.NoError(t, err)
cfg, err := pluginsconfig.ParseDir(cfgPath)
require.NoError(t, err)
require.ElementsMatch(t, expectedPlugins, cfg.Apps, "unexpected global apps")
}