Skip to content

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tenstad committed Feb 20, 2025
1 parent f639152 commit c60f5ca
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/sdk/cloudian/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ func TestListUserCredentials(t *testing.T) {
}

func TestListUsers(t *testing.T) {
var expected []UserID
var expected []User
for i := 0; i < 500; i++ {
expected = append(expected, UserID{GroupID: "QA", UserID: strconv.Itoa(i)})
expected = append(expected, User{UserID: UserID{GroupID: "QA", UserID: strconv.Itoa(i)}})
}

cloudianClient, testServer := mockBy(func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -169,13 +169,18 @@ func TestClient_GetUser(t *testing.T) {
client, testServer := mockBy(func(w http.ResponseWriter, r *http.Request) {
userId := r.URL.Query().Get("userId")
statusCode, _ := strconv.Atoi(userId)
if statusCode == http.StatusOK {
// Only asserting error for now, so user can be empty
json.NewEncoder(w).Encode(User{})
}
w.WriteHeader(statusCode)
})
defer testServer.Close()

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := client.GetUser(context.Background(), tt.user)
// FIXME: Assert user as well, not only error
if !errors.Is(err, tt.wantErr) {
t.Errorf("GetUser() error = %v, wantErr %v", err, tt.wantErr)
}
Expand Down

0 comments on commit c60f5ca

Please sign in to comment.