MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestUpdateIdentity

Function TestUpdateIdentity

api/identity_test.go:132–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

130}
131
132func TestUpdateIdentity(t *testing.T) {
133 router, b, err := setupRouter(t)
134 if err != nil {
135 t.Fatalf("Failed to setup router: %v", err)
136 }
137
138 newIdentity, err := b.CreateIdentity(model.Identity{
139 FirstName: gofakeit.FirstName(),
140 LastName: gofakeit.LastName(),
141 EmailAddress: gofakeit.Email(),
142 OrganizationName: gofakeit.Company(),
143 Category: "individual",
144 })
145 if err != nil {
146 t.Fatalf("Failed to create identity: %v", err)
147 }
148
149 t.Run("Valid update", func(t *testing.T) {
150 updatedIdentity := model.Identity{
151 FirstName: "UpdatedFirstName",
152 LastName: "UpdatedLastName",
153 }
154 payloadBytes, _ := request.ToJsonReq(&updatedIdentity)
155
156 var response map[string]interface{}
157 testRequest := TestRequest{
158 Payload: payloadBytes,
159 Response: &response,
160 Method: "PUT",
161 Route: fmt.Sprintf("/identities/%s", newIdentity.IdentityID),
162 Auth: "",
163 Router: router,
164 }
165
166 resp, err := SetUpTestRequest(testRequest)
167 if err != nil {
168 t.Error(err)
169 return
170 }
171 assert.Equal(t, http.StatusOK, resp.Code)
172 })
173}
174
175func TestGetAllIdentities(t *testing.T) {
176 router, b, err := setupRouter(t)

Callers

nothing calls this directly

Calls 5

ToJsonReqFunction · 0.92
setupRouterFunction · 0.85
SetUpTestRequestFunction · 0.85
CreateIdentityMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected