2017-07-19 03:34:03 -04:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2018-05-03 21:02:44 -04:00
|
|
|
"context"
|
2017-07-19 03:34:03 -04:00
|
|
|
"testing"
|
|
|
|
|
2017-08-21 16:30:09 -04:00
|
|
|
"github.com/docker/cli/internal/test"
|
2017-07-19 03:34:03 -04:00
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
2018-06-08 12:24:26 -04:00
|
|
|
"gotest.tools/assert"
|
|
|
|
"gotest.tools/golden"
|
2017-07-19 03:34:03 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestServiceListOrder(t *testing.T) {
|
|
|
|
cli := test.NewFakeCli(&fakeClient{
|
|
|
|
serviceListFunc: func(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
|
|
|
return []swarm.Service{
|
|
|
|
newService("a57dbe8", "service-1-foo"),
|
|
|
|
newService("a57dbdd", "service-10-foo"),
|
|
|
|
newService("aaaaaaa", "service-2-foo"),
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
})
|
|
|
|
cmd := newListCommand(cli)
|
|
|
|
cmd.Flags().Set("format", "{{.Name}}")
|
2018-03-06 15:13:00 -05:00
|
|
|
assert.NilError(t, cmd.Execute())
|
2017-08-16 12:53:41 -04:00
|
|
|
golden.Assert(t, cli.OutBuffer().String(), "service-list-sort.golden")
|
2017-07-19 03:34:03 -04:00
|
|
|
}
|