mukan-ignite/ignite/config/plugins/parse_test.go
Mukan Erkin Törük 26b204bd04
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
feat: fork Ignite CLI v29 as Mukan Ignite — remove cosmos-sdk restrictions
2026-05-11 03:31:37 +03:00

90 lines
2.2 KiB
Go

package plugins_test
import (
"testing"
"github.com/stretchr/testify/require"
pluginsconfig "github.com/ignite/cli/v29/ignite/config/plugins"
)
func TestParseDir(t *testing.T) {
tests := []struct {
name string
path string
expectedError string
expectedPlugins []pluginsconfig.Plugin
expectedPath string
}{
{
name: "fail: path is not a dir",
path: "testdata/igniteapps.yml",
expectedError: "plugin config parse: path testdata/igniteapps.yml is not a dir",
},
{
name: "fail: path doesn't exists",
path: "testdata/xxx/yyy",
expectedError: "plugin config parse: stat testdata/xxx/yyy: no such file or directory",
},
{
name: "ok: path doesn't contain any config",
path: "testdata/noconfig",
expectedPlugins: nil,
expectedPath: "testdata/noconfig/igniteapps.yml",
},
{
name: "fail: path contains an invalid yml file",
path: "testdata/invalid",
expectedError: "plugin config parse: yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `not yaml !` into plugins.Config",
},
{
name: "ok: path contains a plugin.yml file",
path: "testdata",
expectedPlugins: []pluginsconfig.Plugin{
{
Path: "/path/to/plugin1",
},
{
Path: "/path/to/plugin2",
With: map[string]string{
"bar": "baz",
"foo": "bar",
},
},
},
expectedPath: "testdata/igniteapps.yml",
},
{
name: "ok: path contains a plugin.yaml file",
path: "testdata/other",
expectedPlugins: []pluginsconfig.Plugin{
{
Path: "/path/to/plugin1",
},
{
Path: "/path/to/plugin2",
With: map[string]string{
"bar": "baz",
"foo": "bar",
},
},
},
expectedPath: "testdata/other/igniteapps.yaml",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require := require.New(t)
cfg, err := pluginsconfig.ParseDir(tt.path)
if tt.expectedError != "" {
require.EqualError(err, tt.expectedError)
return
}
require.NoError(err)
require.Equal(tt.expectedPlugins, cfg.Apps)
require.Equal(tt.expectedPath, cfg.Path())
})
}
}