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

Function TestUpdateIdentity

identity_test.go:165–231  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func TestUpdateIdentity(t *testing.T) {
166 datasource, mock, err := newTestDataSource()
167 if err != nil {
168 t.Fatalf("Error creating test data source: %s", err)
169 }
170
171 d, err := NewLedgerForge(datasource)
172 if err != nil {
173 t.Fatalf("Error creating LedgerForge instance: %s", err)
174 }
175
176 identity := &model.Identity{
177 IdentityID: "idt_123",
178 IdentityType: "individual",
179 OrganizationName: "Test Org",
180 Category: "Test Category",
181 FirstName: "John",
182 LastName: "Doe",
183 OtherNames: "Middle",
184 Gender: "Male",
185 DOB: time.Now(),
186 EmailAddress: "john.doe@example.com",
187 PhoneNumber: "1234567890",
188 Nationality: "US",
189 Street: "123 Main St",
190 Country: "United States",
191 State: "NY",
192 PostCode: "10001",
193 City: "New York",
194 MetaData: map[string]interface{}{"key": "value"},
195 }
196
197 // Marshal the metadata to JSON for the SQL parameter
198 metaDataJSON, err := json.Marshal(identity.MetaData)
199 assert.NoError(t, err)
200
201 // Update the SQL pattern to include meta_data field
202 mock.ExpectExec(`UPDATE ledgerforge\.identity SET identity_type = \$1, first_name = \$2, last_name = \$3, other_names = \$4, gender = \$5, dob = \$6, email_address = \$7, phone_number = \$8, nationality = \$9, organization_name = \$10, category = \$11, street = \$12, country = \$13, state = \$14, post_code = \$15, city = \$16, meta_data = \$17 WHERE identity_id = \$18`).
203 WithArgs(
204 identity.IdentityType,
205 identity.FirstName,
206 identity.LastName,
207 identity.OtherNames,
208 identity.Gender,
209 identity.DOB,
210 identity.EmailAddress,
211 identity.PhoneNumber,
212 identity.Nationality,
213 identity.OrganizationName,
214 identity.Category,
215 identity.Street,
216 identity.Country,
217 identity.State,
218 identity.PostCode,
219 identity.City,
220 metaDataJSON, // Add the meta_data parameter
221 identity.IdentityID, // Update parameter index to $18
222 ).

Callers

nothing calls this directly

Calls 3

UpdateIdentityMethod · 0.95
newTestDataSourceFunction · 0.85
NewLedgerForgeFunction · 0.85

Tested by

no test coverage detected