Skip to content

Commit b295cf7

Browse files
committed
Added additional test cases to address coverage of tests against filtering 'List' functionality
1 parent f69ba17 commit b295cf7

5 files changed

+69
-1
lines changed

admin_invite_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ func TestAdminInvite(t *testing.T) {
106106
ctx := context.Background()
107107

108108
t.Run("ListAdminInvites", func(t *testing.T) {
109+
adminInvites, err := client.ListAdminInvites(ctx, nil, nil)
110+
checks.NoError(t, err, "ListAdminInvites error")
111+
112+
if len(adminInvites.AdminInvites) != 1 {
113+
t.Fatalf("expected 1 admin invite, got %d", len(adminInvites.AdminInvites))
114+
}
115+
116+
if adminInvites.AdminInvites[0].ID != adminInviteID {
117+
t.Errorf("expected admin invite ID %s, got %s", adminInviteID, adminInvites.AdminInvites[0].ID)
118+
}
119+
})
120+
121+
t.Run("ListAdminInvitesFilter", func(t *testing.T) {
109122
limit := 10
110123
after := "after-id"
111124

admin_key_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ func TestAdminKey(t *testing.T) {
127127
}
128128
})
129129

130+
t.Run("ListAdminKeysFilter", func(t *testing.T) {
131+
limit := 5
132+
order := "asc"
133+
after := "after_id"
134+
135+
adminKeys, err := client.ListAdminKeys(ctx, &limit, &order, &after)
136+
checks.NoError(t, err, "ListAdminKeys error")
137+
138+
if len(adminKeys.AdminKeys) != 1 {
139+
t.Fatalf("ListAdminKeys: expected 1 key, got %d", len(adminKeys.AdminKeys))
140+
}
141+
142+
if adminKeys.AdminKeys[0].ID != adminKeyID {
143+
t.Fatalf("ListAdminKeys: expected key ID %s, got %s", adminKeyID, adminKeys.AdminKeys[0].ID)
144+
}
145+
})
146+
130147
t.Run("CreateAdminKey", func(t *testing.T) {
131148
adminKey, err := client.CreateAdminKey(ctx, adminKeyName)
132149
checks.NoError(t, err, "CreateAdminKey error")

admin_project_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ func TestAdminProject(t *testing.T) {
107107
ctx := context.Background()
108108

109109
t.Run("ListAdminProjects", func(t *testing.T) {
110-
adminProjects, err := client.ListAdminProjects(ctx, nil, nil, nil)
110+
limit := 5
111+
after := "after_id"
112+
includeArchived := true
113+
114+
adminProjects, err := client.ListAdminProjects(ctx, &limit, &after, &includeArchived)
111115
checks.NoError(t, err, "ListAdminProjects error")
112116

113117
if len(adminProjects.Data) != 1 {

admin_project_user_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,23 @@ func TestAdminProjectUser(t *testing.T) {
111111
}
112112
})
113113

114+
t.Run("ListAdminProjectUsersFilter", func(t *testing.T) {
115+
limit := 5
116+
after := "after_id"
117+
118+
adminProjectUsers, err := client.ListAdminProjectUsers(ctx, adminProjectID, &limit, &after)
119+
checks.NoError(t, err, "ListAdminProjectUsers error")
120+
121+
if len(adminProjectUsers.Data) != 1 {
122+
t.Errorf("expected 1 project user, got %d", len(adminProjectUsers.Data))
123+
}
124+
125+
adminProjectUser := adminProjectUsers.Data[0]
126+
if adminProjectUser.ID != adminProjectUserID {
127+
t.Errorf("expected user ID %s, got %s", adminProjectUserID, adminProjectUser.ID)
128+
}
129+
})
130+
114131
t.Run("CreateAdminProjectUser", func(t *testing.T) {
115132
adminProjectUser, err := client.CreateAdminProjectUser(
116133
ctx,

admin_user_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ func TestAdminUser(t *testing.T) {
9999
}
100100
})
101101

102+
t.Run("ListAdminUsersFilter", func(t *testing.T) {
103+
limit := 10
104+
after := "after-id"
105+
emails := []string{"test@here.com"}
106+
107+
response, err := client.ListAdminUsers(ctx, &limit, &after, &emails)
108+
checks.NoError(t, err, "AdminListUsers error")
109+
110+
if len(response.User) != 1 {
111+
t.Errorf("AdminListUsers returned %d users, want 1", len(response.User))
112+
}
113+
114+
if response.User[0].ID != adminUserID {
115+
t.Errorf("AdminListUsers returned user ID %s, want %s", response.User[0].ID, adminUserID)
116+
}
117+
})
118+
102119
t.Run("ModifyAdminUser", func(t *testing.T) {
103120
response, err := client.ModifyAdminUser(ctx, adminUserID, adminUserRole)
104121
checks.NoError(t, err, "ModifyAdminUser error")

0 commit comments

Comments
 (0)