Skip to content

Commit 0dabdd1

Browse files
committed
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 977d3ae (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>
1 parent 3349492 commit 0dabdd1

2 files changed

Lines changed: 26 additions & 42 deletions

File tree

cli/command/cli_test.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"net"
1010
"net/http"
1111
"net/http/httptest"
12-
"os"
1312
"path/filepath"
1413
"runtime"
1514
"strings"
@@ -19,7 +18,6 @@ import (
1918
"github.com/docker/cli/cli/config"
2019
"github.com/docker/cli/cli/config/configfile"
2120
"github.com/docker/cli/cli/flags"
22-
"github.com/docker/cli/cli/streams"
2321
"github.com/docker/docker/api"
2422
"github.com/docker/docker/api/types"
2523
"github.com/docker/docker/client"
@@ -256,46 +254,6 @@ func TestInitializeFromClientHangs(t *testing.T) {
256254
}
257255
}
258256

259-
// The CLI no longer disables/hides experimental CLI features, however, we need
260-
// to verify that existing configuration files do not break
261-
func TestExperimentalCLI(t *testing.T) {
262-
defaultVersion := "v1.55"
263-
264-
testcases := []struct {
265-
doc string
266-
configfile string
267-
}{
268-
{
269-
doc: "default",
270-
configfile: `{}`,
271-
},
272-
{
273-
doc: "experimental",
274-
configfile: `{
275-
"experimental": "enabled"
276-
}`,
277-
},
278-
}
279-
280-
for _, tc := range testcases {
281-
t.Run(tc.doc, func(t *testing.T) {
282-
dir := fs.NewDir(t, tc.doc, fs.WithFile("config.json", tc.configfile))
283-
defer dir.Remove()
284-
apiclient := &fakeClient{
285-
version: defaultVersion,
286-
pingFunc: func() (types.Ping, error) {
287-
return types.Ping{Experimental: true, OSType: "linux", APIVersion: defaultVersion}, nil
288-
},
289-
}
290-
291-
cli := &DockerCli{client: apiclient, err: streams.NewOut(os.Stderr)}
292-
config.SetDir(dir.Path())
293-
err := cli.Initialize(flags.NewClientOptions())
294-
assert.NilError(t, err)
295-
})
296-
}
297-
}
298-
299257
func TestNewDockerCliAndOperators(t *testing.T) {
300258
// Test default operations and also overriding default ones
301259
cli, err := NewDockerCli(WithInputStream(io.NopCloser(strings.NewReader("some input"))))

cli/config/config_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,32 @@ func TestLoadDefaultConfigFile(t *testing.T) {
398398
})
399399
}
400400

401+
// The CLI no longer disables/hides experimental CLI features, however, we need
402+
// to verify that existing configuration files do not break
403+
func TestLoadLegacyExperimental(t *testing.T) {
404+
tests := []struct {
405+
doc string
406+
configfile string
407+
}{
408+
{
409+
doc: "default",
410+
configfile: `{}`,
411+
},
412+
{
413+
doc: "experimental",
414+
configfile: `{
415+
"experimental": "enabled"
416+
}`,
417+
},
418+
}
419+
for _, tc := range tests {
420+
t.Run(tc.doc, func(t *testing.T) {
421+
_, err := LoadFromReader(strings.NewReader(tc.configfile))
422+
assert.NilError(t, err)
423+
})
424+
}
425+
}
426+
401427
func TestConfigPath(t *testing.T) {
402428
oldDir := Dir()
403429

0 commit comments

Comments
 (0)