cli/command: move TestExperimentalCLI to cli/config
This test was only testing whether we could load a legacy config-file that contained the "experimental" (experimental CLI) option. Experimental cli options are disabled since 977d3ae046ec6c64be8788a8712251ed547a2bdb (20.10), and now enabled by default, but we should not fail to start the cli if the config-file contains the option. Move the test to the config package, as it doesn't need the cli for this. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
33494921b8
commit
0dabdd1a0d
@ -9,7 +9,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -19,7 +18,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/config"
|
"github.com/docker/cli/cli/config"
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
"github.com/docker/cli/cli/flags"
|
"github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/cli/streams"
|
|
||||||
"github.com/docker/docker/api"
|
"github.com/docker/docker/api"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
@ -256,46 +254,6 @@ func TestInitializeFromClientHangs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The CLI no longer disables/hides experimental CLI features, however, we need
|
|
||||||
// to verify that existing configuration files do not break
|
|
||||||
func TestExperimentalCLI(t *testing.T) {
|
|
||||||
defaultVersion := "v1.55"
|
|
||||||
|
|
||||||
testcases := []struct {
|
|
||||||
doc string
|
|
||||||
configfile string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
doc: "default",
|
|
||||||
configfile: `{}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
doc: "experimental",
|
|
||||||
configfile: `{
|
|
||||||
"experimental": "enabled"
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testcases {
|
|
||||||
t.Run(tc.doc, func(t *testing.T) {
|
|
||||||
dir := fs.NewDir(t, tc.doc, fs.WithFile("config.json", tc.configfile))
|
|
||||||
defer dir.Remove()
|
|
||||||
apiclient := &fakeClient{
|
|
||||||
version: defaultVersion,
|
|
||||||
pingFunc: func() (types.Ping, error) {
|
|
||||||
return types.Ping{Experimental: true, OSType: "linux", APIVersion: defaultVersion}, nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
cli := &DockerCli{client: apiclient, err: streams.NewOut(os.Stderr)}
|
|
||||||
config.SetDir(dir.Path())
|
|
||||||
err := cli.Initialize(flags.NewClientOptions())
|
|
||||||
assert.NilError(t, err)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewDockerCliAndOperators(t *testing.T) {
|
func TestNewDockerCliAndOperators(t *testing.T) {
|
||||||
// Test default operations and also overriding default ones
|
// Test default operations and also overriding default ones
|
||||||
cli, err := NewDockerCli(WithInputStream(io.NopCloser(strings.NewReader("some input"))))
|
cli, err := NewDockerCli(WithInputStream(io.NopCloser(strings.NewReader("some input"))))
|
||||||
|
@ -398,6 +398,32 @@ func TestLoadDefaultConfigFile(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The CLI no longer disables/hides experimental CLI features, however, we need
|
||||||
|
// to verify that existing configuration files do not break
|
||||||
|
func TestLoadLegacyExperimental(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
doc string
|
||||||
|
configfile string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
doc: "default",
|
||||||
|
configfile: `{}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
doc: "experimental",
|
||||||
|
configfile: `{
|
||||||
|
"experimental": "enabled"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range tests {
|
||||||
|
t.Run(tc.doc, func(t *testing.T) {
|
||||||
|
_, err := LoadFromReader(strings.NewReader(tc.configfile))
|
||||||
|
assert.NilError(t, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestConfigPath(t *testing.T) {
|
func TestConfigPath(t *testing.T) {
|
||||||
oldDir := Dir()
|
oldDir := Dir()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user