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

Function TestGetAllIdentities

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

Source from the content-addressed store, hash-verified

126}
127
128func TestGetAllIdentities(t *testing.T) {
129 datasource, mock, err := newTestDataSource()
130 if err != nil {
131 t.Fatalf("Error creating test data source: %s", err)
132 }
133
134 d, err := NewLedgerForge(datasource)
135 if err != nil {
136 t.Fatalf("Error creating LedgerForge instance: %s", err)
137 }
138
139 rows := sqlmock.NewRows([]string{
140 "identity_id", "identity_type", "first_name", "last_name", "other_names", "gender", "dob",
141 "email_address", "phone_number", "nationality", "organization_name", "category",
142 "street", "country", "state", "post_code", "city", "created_at", "meta_data",
143 }).AddRow(
144 "idt_12345", "individual", "John", "Doe", "Other Names", "Male", time.Now(),
145 "john@example.com", "1234567890", "Nationality", "Organization", "Category",
146 "Street", "Country", "State", "PostCode", "City", time.Now(), `{"key":"value"}`,
147 ).AddRow(
148 "idt_4442345", "individual", "John", "Doe", "Other Names", "Male", time.Now(),
149 "john@example.com", "1234567890", "Nationality", "Organization", "Category",
150 "Street", "Country", "State", "PostCode", "City", time.Now(), `{"key":"value"}`,
151 )
152
153 mock.ExpectQuery("SELECT .* FROM ledgerforge.identity").WillReturnRows(rows)
154
155 result, err := d.GetAllIdentities()
156
157 assert.NoError(t, err)
158 assert.Len(t, result, 2)
159
160 if err := mock.ExpectationsWereMet(); err != nil {
161 t.Errorf("there were unfulfilled expectations: %s", err)
162 }
163}
164
165func TestUpdateIdentity(t *testing.T) {
166 datasource, mock, err := newTestDataSource()

Callers

nothing calls this directly

Calls 3

GetAllIdentitiesMethod · 0.95
newTestDataSourceFunction · 0.85
NewLedgerForgeFunction · 0.85

Tested by

no test coverage detected