docker-cli/e2e/cli-plugins/config_test.go
Sebastiaan van Stijn b10b79e6fd
cli-plugins: minor cleanups: use Println
- use Println to print newline instead of custom format
- suppress some errors to make my IDE and linters happier
- use res.Assert() with icmd.Expected{} where possible to make
  assertions not depend on newline / whitespace randomness
- use apiClient instead of client for the API client to
  prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-03 12:18:07 +01:00

35 lines
682 B
Go

package cliplugins
import (
"path/filepath"
"testing"
"github.com/docker/cli/cli/config"
"gotest.tools/v3/assert"
"gotest.tools/v3/icmd"
)
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",
},
})
}