2019-02-18 06:49:41 -05:00
|
|
|
package cliplugins
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/cli/cli/config"
|
2020-02-22 12:12:14 -05:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
"gotest.tools/v3/icmd"
|
2019-02-18 06:49:41 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestConfig(t *testing.T) {
|
|
|
|
run, cfg, cleanup := prepare(t)
|
|
|
|
defer cleanup()
|
|
|
|
|
|
|
|
cfg.SetPluginConfig("helloworld", "who", "Cambridge")
|
|
|
|
err := cfg.Save()
|
|
|
|
assert.NilError(t, err)
|
|
|
|
|
|
|
|
res := icmd.RunCmd(run("helloworld"))
|
|
|
|
res.Assert(t, icmd.Expected{
|
|
|
|
ExitCode: 0,
|
|
|
|
Out: "Hello Cambridge!",
|
|
|
|
})
|
|
|
|
|
|
|
|
cfg2, err := config.Load(filepath.Dir(cfg.GetFilename()))
|
|
|
|
assert.NilError(t, err)
|
|
|
|
assert.DeepEqual(t, cfg2.Plugins, map[string]map[string]string{
|
|
|
|
"helloworld": {
|
|
|
|
"who": "Cambridge",
|
|
|
|
"lastwho": "Cambridge",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|