Skip to content

Commit

Permalink
Merge branch 'main' into less_urn_priority
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Sep 11, 2023
2 parents 5f3289f + 4d6ec09 commit 6454283
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/models/contacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ SELECT id, org_id, contact_id, identity, priority, scheme, path, display, auth,
FROM contacts_contacturn
WHERE id = ANY($1)`

// LoadContactURNs fetches contact URNs by their ids
func LoadContactURNs(ctx context.Context, db DBorTx, ids []URNID) ([]*ContactURN, error) {
rows, err := db.QueryxContext(ctx, sqlSelectURNsByID, pq.Array(ids))
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions core/models/contacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,18 @@ func TestUpdateContactURNs(t *testing.T) {
assertdb.Query(t, rt.DB, `SELECT count(*) FROM contacts_contacturn`).Returns(numInitialURNs + 3)
}

func TestLoadContactURNs(t *testing.T) {
ctx, rt := testsuite.Runtime()

oa := testdata.Org1.Load(rt)
_, _, cathyURNs := testdata.Cathy.Load(rt, oa)
_, _, bobURNs := testdata.Bob.Load(rt, oa)

urns, err := models.LoadContactURNs(ctx, rt.DB, []models.URNID{cathyURNs[0].ID, bobURNs[0].ID})
assert.NoError(t, err)
assert.ElementsMatch(t, []*models.ContactURN{cathyURNs[0], bobURNs[0]}, urns)
}

func TestLockContacts(t *testing.T) {
ctx, rt := testsuite.Runtime()

Expand Down

0 comments on commit 6454283

Please sign in to comment.