Update FakeCli to remove duplication in tests.

Use byte buffers by default, since that is what is done most of the time.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin
2017-07-05 14:19:52 -04:00
parent 6908e58f0f
commit 69b142b52a
53 changed files with 182 additions and 168 deletions

View File

@ -48,7 +48,7 @@ func TestListErrors(t *testing.T) {
}
for _, tc := range testCases {
cmd := newListCommand(test.NewFakeCli(&fakeClient{
cmd := newListCommand(test.NewFakeCliWithOutput(&fakeClient{
serviceListFunc: tc.serviceListFunc,
}, &bytes.Buffer{}))
cmd.SetArgs(tc.args)
@ -62,7 +62,7 @@ func TestListErrors(t *testing.T) {
func TestListWithFormat(t *testing.T) {
buf := new(bytes.Buffer)
cmd := newListCommand(test.NewFakeCli(&fakeClient{
cmd := newListCommand(test.NewFakeCliWithOutput(&fakeClient{
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
*Service(
@ -81,7 +81,7 @@ func TestListWithFormat(t *testing.T) {
func TestListWithoutFormat(t *testing.T) {
buf := new(bytes.Buffer)
cmd := newListCommand(test.NewFakeCli(&fakeClient{
cmd := newListCommand(test.NewFakeCliWithOutput(&fakeClient{
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
*Service(
@ -99,7 +99,7 @@ func TestListWithoutFormat(t *testing.T) {
func TestListOrder(t *testing.T) {
buf := new(bytes.Buffer)
cmd := newListCommand(test.NewFakeCli(&fakeClient{
cmd := newListCommand(test.NewFakeCliWithOutput(&fakeClient{
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
*Service(