Skip to content

Commit f59f511

Browse files
Fix fixture consistency, fix existing unit tests
1 parent 64a33f6 commit f59f511

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

models/fixtures/org_user.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,16 @@
4545
uid: 24
4646
org_id: 25
4747
is_public: true
48+
49+
-
50+
id: 9
51+
uid: 27
52+
org_id: 3
53+
is_public: true
54+
55+
-
56+
id: 10
57+
uid: 27
58+
org_id: 6
59+
is_public: true
60+

models/fixtures/user.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
avatar: avatar3
5151
avatar_email: [email protected]
5252
num_repos: 3
53-
num_members: 2
54-
num_teams: 3
53+
num_members: 3
54+
num_teams: 4
5555

5656
-
5757
id: 4
@@ -102,8 +102,8 @@
102102
avatar: avatar6
103103
avatar_email: [email protected]
104104
num_repos: 0
105-
num_members: 1
106-
num_teams: 1
105+
num_members: 2
106+
num_teams: 2
107107

108108
-
109109
id: 7

models/org_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,22 @@ func TestUser_GetTeams(t *testing.T) {
8787
assert.NoError(t, PrepareTestDatabase())
8888
org := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
8989
assert.NoError(t, org.GetTeams())
90-
if assert.Len(t, org.Teams, 3) {
90+
if assert.Len(t, org.Teams, 4) {
9191
assert.Equal(t, int64(1), org.Teams[0].ID)
9292
assert.Equal(t, int64(2), org.Teams[1].ID)
93-
assert.Equal(t, int64(7), org.Teams[2].ID)
93+
assert.Equal(t, int64(12), org.Teams[2].ID)
94+
assert.Equal(t, int64(7), org.Teams[3].ID)
9495
}
9596
}
9697

9798
func TestUser_GetMembers(t *testing.T) {
9899
assert.NoError(t, PrepareTestDatabase())
99100
org := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
100101
assert.NoError(t, org.GetMembers())
101-
if assert.Len(t, org.Members, 2) {
102+
if assert.Len(t, org.Members, 3) {
102103
assert.Equal(t, int64(2), org.Members[0].ID)
103-
assert.Equal(t, int64(4), org.Members[1].ID)
104+
assert.Equal(t, int64(27), org.Members[1].ID)
105+
assert.Equal(t, int64(4), org.Members[2].ID)
104106
}
105107
}
106108

@@ -395,7 +397,7 @@ func TestGetOrgUsersByOrgID(t *testing.T) {
395397

396398
orgUsers, err := GetOrgUsersByOrgID(3)
397399
assert.NoError(t, err)
398-
if assert.Len(t, orgUsers, 2) {
400+
if assert.Len(t, orgUsers, 3) {
399401
assert.Equal(t, OrgUser{
400402
ID: orgUsers[0].ID,
401403
OrgID: 3,

models/user_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ func TestSearchUsers(t *testing.T) {
153153
}
154154

155155
testUserSuccess(&SearchUserOptions{OrderBy: "id ASC", Page: 1},
156-
[]int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24})
156+
[]int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27})
157157

158158
testUserSuccess(&SearchUserOptions{Page: 1, IsActive: util.OptionalBoolFalse},
159159
[]int64{9})
160160

161161
testUserSuccess(&SearchUserOptions{OrderBy: "id ASC", Page: 1, IsActive: util.OptionalBoolTrue},
162-
[]int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24})
162+
[]int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27})
163163

164164
testUserSuccess(&SearchUserOptions{Keyword: "user1", OrderBy: "id ASC", Page: 1, IsActive: util.OptionalBoolTrue},
165165
[]int64{1, 10, 11, 12, 13, 14, 15, 16, 18})

models/userlist_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ func TestUserListIsPublicMember(t *testing.T) {
1717
orgid int64
1818
expected map[int64]bool
1919
}{
20-
{3, map[int64]bool{2: true, 4: false}},
21-
{6, map[int64]bool{5: true}},
20+
{3, map[int64]bool{2: true, 4: false, 27: true}},
21+
{6, map[int64]bool{5: true, 27: true}},
2222
{7, map[int64]bool{5: false}},
2323
{25, map[int64]bool{24: true}},
2424
{22, map[int64]bool{}},
@@ -43,8 +43,8 @@ func TestUserListIsUserOrgOwner(t *testing.T) {
4343
orgid int64
4444
expected map[int64]bool
4545
}{
46-
{3, map[int64]bool{2: true, 4: false}},
47-
{6, map[int64]bool{5: true}},
46+
{3, map[int64]bool{2: true, 4: false, 27: false}},
47+
{6, map[int64]bool{5: true, 27: false}},
4848
{7, map[int64]bool{5: true}},
4949
{25, map[int64]bool{24: false}}, // ErrTeamNotExist
5050
{22, map[int64]bool{}}, // No member
@@ -69,8 +69,8 @@ func TestUserListIsTwoFaEnrolled(t *testing.T) {
6969
orgid int64
7070
expected map[int64]bool
7171
}{
72-
{3, map[int64]bool{2: false, 4: false}},
73-
{6, map[int64]bool{5: false}},
72+
{3, map[int64]bool{2: false, 4: false, 27: false}},
73+
{6, map[int64]bool{5: false, 27: false}},
7474
{7, map[int64]bool{5: false}},
7575
{25, map[int64]bool{24: true}},
7676
{22, map[int64]bool{}},

0 commit comments

Comments
 (0)