mirror of https://github.com/docker/cli.git
Remove unnecessary use of SetConfigfile
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
69b142b52a
commit
3da0cbfdd1
|
@ -68,7 +68,6 @@ func TestConfigList(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newConfigListCommand(cli)
|
cmd := newConfigListCommand(cli)
|
||||||
cmd.SetOutput(buf)
|
cmd.SetOutput(buf)
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
|
@ -89,7 +88,6 @@ func TestConfigListWithQuietOption(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newConfigListCommand(cli)
|
cmd := newConfigListCommand(cli)
|
||||||
cmd.Flags().Set("quiet", "true")
|
cmd.Flags().Set("quiet", "true")
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
|
@ -110,7 +108,7 @@ func TestConfigListWithConfigFormat(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{
|
cli.SetConfigFile(&configfile.ConfigFile{
|
||||||
ConfigFormat: "{{ .Name }} {{ .Labels }}",
|
ConfigFormat: "{{ .Name }} {{ .Labels }}",
|
||||||
})
|
})
|
||||||
cmd := newConfigListCommand(cli)
|
cmd := newConfigListCommand(cli)
|
||||||
|
@ -162,7 +160,6 @@ func TestConfigListWithFilter(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newConfigListCommand(cli)
|
cmd := newConfigListCommand(cli)
|
||||||
cmd.Flags().Set("filter", "name=foo")
|
cmd.Flags().Set("filter", "name=foo")
|
||||||
cmd.Flags().Set("filter", "label=lbl1=Label-bar")
|
cmd.Flags().Set("filter", "label=lbl1=Label-bar")
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
|
||||||
"github.com/docker/cli/cli/internal/test"
|
"github.com/docker/cli/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/pkg/testutil"
|
"github.com/docker/docker/pkg/testutil"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
type arguments struct {
|
type arguments struct {
|
||||||
|
@ -79,9 +78,7 @@ func TestParseExec(t *testing.T) {
|
||||||
|
|
||||||
for valid, expectedExecConfig := range valids {
|
for valid, expectedExecConfig := range valids {
|
||||||
execConfig, err := parseExec(&valid.options, valid.execCmd)
|
execConfig, err := parseExec(&valid.options, valid.execCmd)
|
||||||
if err != nil {
|
require.NoError(t, err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !compareExecConfig(expectedExecConfig, execConfig) {
|
if !compareExecConfig(expectedExecConfig, execConfig) {
|
||||||
t.Fatalf("Expected [%v] for %v, got [%v]", expectedExecConfig, valid, execConfig)
|
t.Fatalf("Expected [%v] for %v, got [%v]", expectedExecConfig, valid, execConfig)
|
||||||
}
|
}
|
||||||
|
@ -138,10 +135,7 @@ func TestNewExecCommandErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
cli := test.NewFakeCli(&fakeClient{containerInspectFunc: tc.containerInspectFunc})
|
||||||
conf := configfile.ConfigFile{}
|
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{containerInspectFunc: tc.containerInspectFunc}, buf)
|
|
||||||
cli.SetConfigfile(&conf)
|
|
||||||
cmd := NewExecCommand(cli)
|
cmd := NewExecCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
@ -82,7 +82,7 @@ func TestNewImagesCommandSuccess(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{imageListFunc: tc.imageListFunc}, buf)
|
cli := test.NewFakeCliWithOutput(&fakeClient{imageListFunc: tc.imageListFunc}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{ImagesFormat: tc.imageFormat})
|
cli.SetConfigFile(&configfile.ConfigFile{ImagesFormat: tc.imageFormat})
|
||||||
cmd := NewImagesCommand(cli)
|
cmd := NewImagesCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
@ -95,7 +95,7 @@ func TestNewImagesCommandSuccess(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewListCommandAlias(t *testing.T) {
|
func TestNewListCommandAlias(t *testing.T) {
|
||||||
cmd := newListCommand(test.NewFakeCliWithOutput(&fakeClient{}, new(bytes.Buffer)))
|
cmd := newListCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
assert.True(t, cmd.HasAlias("images"))
|
assert.True(t, cmd.HasAlias("images"))
|
||||||
assert.True(t, cmd.HasAlias("list"))
|
assert.True(t, cmd.HasAlias("list"))
|
||||||
assert.False(t, cmd.HasAlias("other"))
|
assert.False(t, cmd.HasAlias("other"))
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
|
||||||
"github.com/docker/cli/cli/internal/test"
|
"github.com/docker/cli/cli/internal/test"
|
||||||
"github.com/docker/docker/pkg/testutil"
|
"github.com/docker/docker/pkg/testutil"
|
||||||
"github.com/docker/docker/pkg/testutil/golden"
|
"github.com/docker/docker/pkg/testutil/golden"
|
||||||
|
@ -41,9 +39,7 @@ func TestNewPullCommandErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{}, buf)
|
|
||||||
cli.SetConfigfile(configfile.New("filename"))
|
|
||||||
cmd := NewPullCommand(cli)
|
cmd := NewPullCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
@ -66,15 +62,13 @@ func TestNewPullCommandSuccess(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{}, buf)
|
|
||||||
cli.SetConfigfile(configfile.New("filename"))
|
|
||||||
cmd := NewPullCommand(cli)
|
cmd := NewPullCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
actual := buf.String()
|
actual := cli.OutBuffer().String()
|
||||||
expected := string(golden.Get(t, []byte(actual), fmt.Sprintf("pull-command-success.%s.golden", tc.name))[:])
|
expected := string(golden.Get(t, []byte(actual), fmt.Sprintf("pull-command-success.%s.golden", tc.name))[:])
|
||||||
testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, expected)
|
testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, expected)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
|
||||||
"github.com/docker/cli/cli/internal/test"
|
"github.com/docker/cli/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/pkg/testutil"
|
"github.com/docker/docker/pkg/testutil"
|
||||||
|
@ -47,9 +45,7 @@ func TestNewPushCommandErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
cli := test.NewFakeCli(&fakeClient{imagePushFunc: tc.imagePushFunc})
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{imagePushFunc: tc.imagePushFunc}, buf)
|
|
||||||
cli.SetConfigfile(configfile.New("filename"))
|
|
||||||
cmd := NewPushCommand(cli)
|
cmd := NewPushCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
@ -68,13 +64,11 @@ func TestNewPushCommandSuccess(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{
|
|
||||||
imagePushFunc: func(ref string, options types.ImagePushOptions) (io.ReadCloser, error) {
|
imagePushFunc: func(ref string, options types.ImagePushOptions) (io.ReadCloser, error) {
|
||||||
return ioutil.NopCloser(strings.NewReader("")), nil
|
return ioutil.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
}, buf)
|
})
|
||||||
cli.SetConfigfile(configfile.New("filename"))
|
|
||||||
cmd := NewPushCommand(cli)
|
cmd := NewPushCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
@ -42,12 +42,10 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{
|
|
||||||
nodeListFunc: tc.nodeListFunc,
|
nodeListFunc: tc.nodeListFunc,
|
||||||
infoFunc: tc.infoFunc,
|
infoFunc: tc.infoFunc,
|
||||||
}, buf)
|
})
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
assert.EqualError(t, cmd.Execute(), tc.expectedError)
|
assert.EqualError(t, cmd.Execute(), tc.expectedError)
|
||||||
|
@ -55,8 +53,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNodeList(t *testing.T) {
|
func TestNodeList(t *testing.T) {
|
||||||
buf := new(bytes.Buffer)
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{
|
|
||||||
nodeListFunc: func() ([]swarm.Node, error) {
|
nodeListFunc: func() ([]swarm.Node, error) {
|
||||||
return []swarm.Node{
|
return []swarm.Node{
|
||||||
*Node(NodeID("nodeID1"), Hostname("nodeHostname1"), Manager(Leader())),
|
*Node(NodeID("nodeID1"), Hostname("nodeHostname1"), Manager(Leader())),
|
||||||
|
@ -71,13 +68,14 @@ func TestNodeList(t *testing.T) {
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
})
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
assert.Contains(t, buf.String(), `nodeID1 * nodeHostname1 Ready Active Leader`)
|
out := cli.OutBuffer().String()
|
||||||
assert.Contains(t, buf.String(), `nodeID2 nodeHostname2 Ready Active Reachable`)
|
assert.Contains(t, out, `nodeID1 * nodeHostname1 Ready Active Leader`)
|
||||||
assert.Contains(t, buf.String(), `nodeID3 nodeHostname3 Ready Active`)
|
assert.Contains(t, out, `nodeID2 nodeHostname2 Ready Active Reachable`)
|
||||||
|
assert.Contains(t, out, `nodeID3 nodeHostname3 Ready Active`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNodeListQuietShouldOnlyPrintIDs(t *testing.T) {
|
func TestNodeListQuietShouldOnlyPrintIDs(t *testing.T) {
|
||||||
|
@ -89,7 +87,6 @@ func TestNodeListQuietShouldOnlyPrintIDs(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
cmd.Flags().Set("quiet", "true")
|
cmd.Flags().Set("quiet", "true")
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
|
@ -100,7 +97,6 @@ func TestNodeListQuietShouldOnlyPrintIDs(t *testing.T) {
|
||||||
func TestNodeListContainsHostname(t *testing.T) {
|
func TestNodeListContainsHostname(t *testing.T) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{}, buf)
|
cli := test.NewFakeCliWithOutput(&fakeClient{}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
assert.Contains(t, buf.String(), "HOSTNAME")
|
assert.Contains(t, buf.String(), "HOSTNAME")
|
||||||
|
@ -124,7 +120,7 @@ func TestNodeListDefaultFormat(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{
|
cli.SetConfigFile(&configfile.ConfigFile{
|
||||||
NodesFormat: "{{.ID}}: {{.Hostname}} {{.Status}}/{{.ManagerStatus}}",
|
NodesFormat: "{{.ID}}: {{.Hostname}} {{.Status}}/{{.ManagerStatus}}",
|
||||||
})
|
})
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
|
@ -151,7 +147,7 @@ func TestNodeListFormat(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{
|
cli.SetConfigFile(&configfile.ConfigFile{
|
||||||
NodesFormat: "{{.ID}}: {{.Hostname}} {{.Status}}/{{.ManagerStatus}}",
|
NodesFormat: "{{.ID}}: {{.Hostname}} {{.Status}}/{{.ManagerStatus}}",
|
||||||
})
|
})
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
|
|
|
@ -68,7 +68,6 @@ func TestSecretList(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newSecretListCommand(cli)
|
cmd := newSecretListCommand(cli)
|
||||||
cmd.SetOutput(buf)
|
cmd.SetOutput(buf)
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
|
@ -89,7 +88,6 @@ func TestSecretListWithQuietOption(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newSecretListCommand(cli)
|
cmd := newSecretListCommand(cli)
|
||||||
cmd.Flags().Set("quiet", "true")
|
cmd.Flags().Set("quiet", "true")
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
|
@ -110,7 +108,7 @@ func TestSecretListWithConfigFormat(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{
|
cli.SetConfigFile(&configfile.ConfigFile{
|
||||||
SecretFormat: "{{ .Name }} {{ .Labels }}",
|
SecretFormat: "{{ .Name }} {{ .Labels }}",
|
||||||
})
|
})
|
||||||
cmd := newSecretListCommand(cli)
|
cmd := newSecretListCommand(cli)
|
||||||
|
@ -162,7 +160,6 @@ func TestSecretListWithFilter(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newSecretListCommand(cli)
|
cmd := newSecretListCommand(cli)
|
||||||
cmd.Flags().Set("filter", "name=foo")
|
cmd.Flags().Set("filter", "name=foo")
|
||||||
cmd.Flags().Set("filter", "label=lbl1=Label-bar")
|
cmd.Flags().Set("filter", "label=lbl1=Label-bar")
|
||||||
|
|
|
@ -73,7 +73,6 @@ func TestStackPsWithQuietOption(t *testing.T) {
|
||||||
return []swarm.Task{*Task(TaskID("id-foo"))}, nil
|
return []swarm.Task{*Task(TaskID("id-foo"))}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newPsCommand(cli)
|
cmd := newPsCommand(cli)
|
||||||
cmd.SetArgs([]string{"foo"})
|
cmd.SetArgs([]string{"foo"})
|
||||||
cmd.Flags().Set("quiet", "true")
|
cmd.Flags().Set("quiet", "true")
|
||||||
|
@ -91,7 +90,6 @@ func TestStackPsWithNoTruncOption(t *testing.T) {
|
||||||
return []swarm.Task{*Task(TaskID("xn4cypcov06f2w8gsbaf2lst3"))}, nil
|
return []swarm.Task{*Task(TaskID("xn4cypcov06f2w8gsbaf2lst3"))}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newPsCommand(cli)
|
cmd := newPsCommand(cli)
|
||||||
cmd.SetArgs([]string{"foo"})
|
cmd.SetArgs([]string{"foo"})
|
||||||
cmd.Flags().Set("no-trunc", "true")
|
cmd.Flags().Set("no-trunc", "true")
|
||||||
|
@ -114,7 +112,6 @@ func TestStackPsWithNoResolveOption(t *testing.T) {
|
||||||
return *Node(NodeName("node-name-bar")), nil, nil
|
return *Node(NodeName("node-name-bar")), nil, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newPsCommand(cli)
|
cmd := newPsCommand(cli)
|
||||||
cmd.SetArgs([]string{"foo"})
|
cmd.SetArgs([]string{"foo"})
|
||||||
cmd.Flags().Set("no-resolve", "true")
|
cmd.Flags().Set("no-resolve", "true")
|
||||||
|
@ -132,7 +129,6 @@ func TestStackPsWithFormat(t *testing.T) {
|
||||||
return []swarm.Task{*Task(TaskServiceID("service-id-foo"))}, nil
|
return []swarm.Task{*Task(TaskServiceID("service-id-foo"))}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newPsCommand(cli)
|
cmd := newPsCommand(cli)
|
||||||
cmd.SetArgs([]string{"foo"})
|
cmd.SetArgs([]string{"foo"})
|
||||||
cmd.Flags().Set("format", "{{ .Name }}")
|
cmd.Flags().Set("format", "{{ .Name }}")
|
||||||
|
@ -149,7 +145,7 @@ func TestStackPsWithConfigFormat(t *testing.T) {
|
||||||
return []swarm.Task{*Task(TaskServiceID("service-id-foo"))}, nil
|
return []swarm.Task{*Task(TaskServiceID("service-id-foo"))}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{
|
cli.SetConfigFile(&configfile.ConfigFile{
|
||||||
TasksFormat: "{{ .Name }}",
|
TasksFormat: "{{ .Name }}",
|
||||||
})
|
})
|
||||||
cmd := newPsCommand(cli)
|
cmd := newPsCommand(cli)
|
||||||
|
@ -177,7 +173,6 @@ func TestStackPsWithoutFormat(t *testing.T) {
|
||||||
return *Node(NodeName("node-name-bar")), nil, nil
|
return *Node(NodeName("node-name-bar")), nil, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newPsCommand(cli)
|
cmd := newPsCommand(cli)
|
||||||
cmd.SetArgs([]string{"foo"})
|
cmd.SetArgs([]string{"foo"})
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
|
|
|
@ -66,12 +66,11 @@ func TestStackServicesErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCliWithOutput(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: tc.serviceListFunc,
|
serviceListFunc: tc.serviceListFunc,
|
||||||
nodeListFunc: tc.nodeListFunc,
|
nodeListFunc: tc.nodeListFunc,
|
||||||
taskListFunc: tc.taskListFunc,
|
taskListFunc: tc.taskListFunc,
|
||||||
}, &bytes.Buffer{})
|
})
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newServicesCommand(cli)
|
cmd := newServicesCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
|
@ -102,7 +101,6 @@ func TestStackServicesWithQuietOption(t *testing.T) {
|
||||||
return []swarm.Service{*Service(ServiceID("id-foo"))}, nil
|
return []swarm.Service{*Service(ServiceID("id-foo"))}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newServicesCommand(cli)
|
cmd := newServicesCommand(cli)
|
||||||
cmd.Flags().Set("quiet", "true")
|
cmd.Flags().Set("quiet", "true")
|
||||||
cmd.SetArgs([]string{"foo"})
|
cmd.SetArgs([]string{"foo"})
|
||||||
|
@ -121,7 +119,6 @@ func TestStackServicesWithFormat(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newServicesCommand(cli)
|
cmd := newServicesCommand(cli)
|
||||||
cmd.SetArgs([]string{"foo"})
|
cmd.SetArgs([]string{"foo"})
|
||||||
cmd.Flags().Set("format", "{{ .Name }}")
|
cmd.Flags().Set("format", "{{ .Name }}")
|
||||||
|
@ -140,7 +137,7 @@ func TestStackServicesWithConfigFormat(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{
|
cli.SetConfigFile(&configfile.ConfigFile{
|
||||||
ServicesFormat: "{{ .Name }}",
|
ServicesFormat: "{{ .Name }}",
|
||||||
})
|
})
|
||||||
cmd := newServicesCommand(cli)
|
cmd := newServicesCommand(cli)
|
||||||
|
@ -169,7 +166,6 @@ func TestStackServicesWithoutFormat(t *testing.T) {
|
||||||
)}, nil
|
)}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newServicesCommand(cli)
|
cmd := newServicesCommand(cli)
|
||||||
cmd.SetArgs([]string{"foo"})
|
cmd.SetArgs([]string{"foo"})
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
|
|
|
@ -67,7 +67,6 @@ func TestVolumeListWithoutFormat(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
actual := buf.String()
|
actual := buf.String()
|
||||||
|
@ -90,7 +89,7 @@ func TestVolumeListWithConfigFormat(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{
|
cli.SetConfigFile(&configfile.ConfigFile{
|
||||||
VolumesFormat: "{{ .Name }} {{ .Driver }} {{ .Labels }}",
|
VolumesFormat: "{{ .Name }} {{ .Driver }} {{ .Labels }}",
|
||||||
})
|
})
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
|
@ -115,7 +114,6 @@ func TestVolumeListWithFormat(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(&configfile.ConfigFile{})
|
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
cmd.Flags().Set("format", "{{ .Name }} {{ .Driver }} {{ .Labels }}")
|
cmd.Flags().Set("format", "{{ .Name }} {{ .Driver }} {{ .Labels }}")
|
||||||
assert.NoError(t, cmd.Execute())
|
assert.NoError(t, cmd.Execute())
|
||||||
|
|
|
@ -55,8 +55,8 @@ func (c *FakeCli) SetErr(err *bytes.Buffer) {
|
||||||
c.err = err
|
c.err = err
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConfigfile sets the "fake" config file
|
// SetConfigFile sets the "fake" config file
|
||||||
func (c *FakeCli) SetConfigfile(configfile *configfile.ConfigFile) {
|
func (c *FakeCli) SetConfigFile(configfile *configfile.ConfigFile) {
|
||||||
c.configfile = configfile
|
c.configfile = configfile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue