Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
73 lines
1.8 KiB
Text
73 lines
1.8 KiB
Text
package integration_test
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
pluginsconfig "github.com/ignite/cli/v29/ignite/config/plugins"
|
|
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step"
|
|
"github.com/ignite/cli/v29/ignite/services/plugin"
|
|
envtest "github.com/ignite/cli/v29/integration"
|
|
)
|
|
|
|
func Test<%= Title %>(t *testing.T) {
|
|
var (
|
|
require = require.New(t)
|
|
env = envtest.New(t)
|
|
app = env.ScaffoldApp("<%= AppName %>-app")
|
|
)
|
|
|
|
dir, err := os.Getwd()
|
|
require.NoError(err)
|
|
pluginPath := filepath.Join(filepath.Dir(filepath.Dir(dir)), "<%= Name %>")
|
|
|
|
env.Must(env.Exec("install <%= Name %> 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)
|
|
|
|
buf := &bytes.Buffer{}
|
|
env.Must(env.Exec("run <%= Name %>",
|
|
step.NewSteps(step.New(
|
|
step.Exec(
|
|
envtest.IgniteApp,
|
|
"<%= Name %>",
|
|
"hello",
|
|
),
|
|
step.Workdir(app.SourcePath()),
|
|
step.Stdout(buf),
|
|
step.Stderr(buf),
|
|
)),
|
|
))
|
|
require.Equal("Hello, world!\n", 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")
|
|
}
|