add unit test to cover the sort order of network list command

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
This commit is contained in:
Arash Deshmeh
2018-08-01 14:40:41 -04:00
parent ff1a34d9a9
commit 4f388ffca3
2 changed files with 20 additions and 0 deletions

View File

@ -61,3 +61,20 @@ func TestNetworkListWithFlags(t *testing.T) {
assert.NilError(t, cmd.Execute())
golden.Assert(t, strings.TrimSpace(cli.OutBuffer().String()), "network-list.golden")
}
func TestNetworkListSort(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
networkListFunc: func(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
return []types.NetworkResource{
*NetworkResource(NetworkResourceName("network-2-foo")),
*NetworkResource(NetworkResourceName("network-1-foo")),
*NetworkResource(NetworkResourceName("network-10-foo")),
}, nil
},
})
cmd := newListCommand(cli)
cmd.Flags().Set("format", "{{ .Name }}")
assert.NilError(t, cmd.Execute())
golden.Assert(t, cli.OutBuffer().String(), "network-list-sort.golden")
}

View File

@ -0,0 +1,3 @@
network-1-foo
network-10-foo
network-2-foo