-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlist-workspaces_test.go
More file actions
48 lines (39 loc) · 1.32 KB
/
list-workspaces_test.go
File metadata and controls
48 lines (39 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package cmd_test
import (
"testing"
"github.com/codesphere-cloud/cs-go/api"
"github.com/codesphere-cloud/cs-go/cmd"
"github.com/stretchr/testify/assert"
)
func TestListWorkspaces(t *testing.T) {
l := newListWorkspacesCmdWithTeam(0)
client := NewMockClient(t)
client.EXPECT().ListWorkspaces(0).Return([]api.Workspace{}, nil)
w, err := l.ListWorkspaces(client)
assert.Equal(t, w, []api.Workspace{}, "should return empty list of workspaces")
assert.Nil(t, err, "should be nil")
}
func TestListWorkspacesAllTeams(t *testing.T) {
l := newListWorkspacesCmd()
client := NewMockClient(t)
client.EXPECT().ListTeams().Return([]api.Team{{Id: 0}, {Id: 1}}, nil)
expectedWorkspaces := []api.Workspace{
{Id: 0, Name: "fakeForTeam0"},
{Id: 1, Name: "fakeForTeam1"},
}
client.EXPECT().ListWorkspaces(0).Return([]api.Workspace{expectedWorkspaces[0]}, nil)
client.EXPECT().ListWorkspaces(1).Return([]api.Workspace{expectedWorkspaces[1]}, nil)
w, err := l.ListWorkspaces(client)
assert.Equal(t, w, expectedWorkspaces, "should return both workspaces")
assert.Nil(t, err, "should be nil")
}
func newListWorkspacesCmdWithTeam(teamId int) cmd.ListWorkspacesCmd {
return cmd.ListWorkspacesCmd{
Opts: cmd.ListWorkspacesOptions{
TeamId: &teamId,
},
}
}
func newListWorkspacesCmd() cmd.ListWorkspacesCmd {
return cmd.ListWorkspacesCmd{}
}