github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/e2e/cli-plugins/config_test.go (about)

     1  package cliplugins
     2  
     3  import (
     4  	"path/filepath"
     5  	"testing"
     6  
     7  	"github.com/docker/cli/cli/config"
     8  	"gotest.tools/v3/assert"
     9  	"gotest.tools/v3/icmd"
    10  )
    11  
    12  func TestConfig(t *testing.T) {
    13  	run, cfg, cleanup := prepare(t)
    14  	defer cleanup()
    15  
    16  	cfg.SetPluginConfig("helloworld", "who", "Cambridge")
    17  	err := cfg.Save()
    18  	assert.NilError(t, err)
    19  
    20  	res := icmd.RunCmd(run("helloworld"))
    21  	res.Assert(t, icmd.Expected{
    22  		ExitCode: 0,
    23  		Out:      "Hello Cambridge!",
    24  	})
    25  
    26  	cfg2, err := config.Load(filepath.Dir(cfg.GetFilename()))
    27  	assert.NilError(t, err)
    28  	assert.DeepEqual(t, cfg2.Plugins, map[string]map[string]string{
    29  		"helloworld": {
    30  			"who":     "Cambridge",
    31  			"lastwho": "Cambridge",
    32  		},
    33  	})
    34  }