File: config_test.go

package info (click to toggle)
docker.io 27.5.1%2Bdfsg4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,384 kB
  • sloc: sh: 5,847; makefile: 1,146; ansic: 664; python: 162; asm: 133
file content (34 lines) | stat: -rw-r--r-- 683 bytes parent folder | download | duplicates (10)
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
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",
		},
	})
}