Skip to content

Commit

Permalink
test: add handler update tests
Browse files Browse the repository at this point in the history
Closes #325
  • Loading branch information
aeneasr committed Jul 27, 2020
1 parent fe88b42 commit aea1fb8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
20 changes: 20 additions & 0 deletions identity/handler_test.go
Expand Up @@ -234,6 +234,26 @@ func TestHandler(t *testing.T) {
assert.EqualValues(t, "ory street", res.Get("traits.address").String(), "%s", res.Raw)
})

t.Run("case=should be able to update multiple identities", func(t *testing.T) {
for i := 0; i <= 5; i++ {
var cr identity.CreateIdentityRequestPayload
cr.SchemaID = "employee"
cr.Traits = []byte(`{"department": "ory"}`)
res := send(t, "POST", "/identities", http.StatusCreated, &cr)

id := res.Get("id").String()
res = send(t, "PUT", "/identities/"+id, http.StatusOK, &identity.UpdateIdentityRequestPayload{
SchemaID: "employee",
Traits: []byte(`{"email":"` + x.NewUUID().String() + `@ory.sh"}`),
})

res = send(t, "PUT", "/identities/"+id, http.StatusOK, &identity.UpdateIdentityRequestPayload{
SchemaID: "employee",
Traits: []byte(`{}`),
})
}
})

t.Run("case=should list all identities", func(t *testing.T) {
res := get(t, "/identities", http.StatusOK)
assert.Empty(t, res.Get("0.credentials").String(), "%s", res.Raw)
Expand Down
6 changes: 3 additions & 3 deletions internal/testhelpers/json.go
Expand Up @@ -17,7 +17,7 @@ func JSONEq(t *testing.T, expected, actual interface{}, messageAndArgs ...interf
}

func LogJSON(t *testing.T, v interface{}) {
out, err := json.MarshalIndent(v,""," ")
require.NoError(t,err)
t.Logf("\n%s\n---",out)
out, err := json.MarshalIndent(v, "", " ")
require.NoError(t, err)
t.Logf("\n%s\n---", out)
}

0 comments on commit aea1fb8

Please sign in to comment.