Skip to content

Commit

Permalink
added batch list identity handler test
Browse files Browse the repository at this point in the history
Signed-off-by: nxy7 <[email protected]>
  • Loading branch information
nxy7 committed Nov 10, 2023
1 parent 03ffc0a commit 0580c1c
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions identity/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,31 @@ func TestHandler(t *testing.T) {
})

t.Run("suite=create and batch list", func(t *testing.T) {
var _ identity.Identity
// for name, ts := range map[string]*httptest.Server{"public": publicTS, "admin": adminTS} {
t.Run("endpoint=admin", func(t *testing.T) {
_ = get(t, adminTS, "/identities", 200)
var ids []uuid.UUID
identitiesAmount := 5
listAmount := 3
t.Run("case= create multiple identities", func(t *testing.T) {
for i := 0; i < identitiesAmount; i++ {
res := send(t, adminTS, "POST", "/identities", http.StatusCreated, json.RawMessage(`{"traits": {"bar":"baz"}}`))
assert.NotEmpty(t, res.Get("id").String(), "%s", res.Raw)

// assert.Contains(t, res.Raw, "id")
id := x.ParseUUID(res.Get("id").String())
ids = append(ids, id)
}
require.Equal(t, len(ids), identitiesAmount)
})
// }

t.Run("case= list few identities", func(t *testing.T) {
url := "/identities?ids=" + ids[0].String()
for i := 1; i < listAmount; i++ {
url += "&ids=" + ids[i].String()
}
res := get(t, adminTS, url, 200)

identities := res.Array()
require.Equal(t, len(identities), listAmount)
})

})

t.Run("suite=create and update", func(t *testing.T) {
Expand Down

0 comments on commit 0580c1c

Please sign in to comment.