Skip to content

Commit

Permalink
Update test database
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Oct 11, 2023
1 parent 3cf5f98 commit d6ca9e8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Binary file modified mailroom_test.dump
Binary file not shown.
14 changes: 14 additions & 0 deletions testsuite/testdata/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ package testdata

// Constants used in tests, these are tied to the DB created by the RapidPro `mailroom_db` management command.

var AuthGroupIDs = map[string]int{
"Alpha": 1,
"Beta": 2,
"Dashboard": 3,
"Surveyors": 4,
"Customer Support": 5,
"Granters": 6,
"Administrators": 7,
"Editors": 8,
"Viewers": 9,
"Agents": 10,
"Prometheus": 11,
}

var Org1 = &Org{1, "bf0514a5-9407-44c9-b0f9-3f36f9c18414"}
var Admin = &User{3, "[email protected]"}
var Editor = &User{4, "[email protected]"}
Expand Down
4 changes: 2 additions & 2 deletions web/org/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func TestMetrics(t *testing.T) {
defer testsuite.Reset(testsuite.ResetAll)

promToken := "2d26a50841ff48237238bbdd021150f6a33a4196"
rt.DB.MustExec(`INSERT INTO api_apitoken(is_active, org_id, created, key, role_id, user_id) VALUES(TRUE, $1, NOW(), $2, 12, 1);`, testdata.Org1.ID, promToken)
rt.DB.MustExec(`INSERT INTO api_apitoken(is_active, org_id, created, key, role_id, user_id) VALUES(TRUE, $1, NOW(), $2, $3, 1);`, testdata.Org1.ID, promToken, testdata.AuthGroupIDs["Prometheus"])

adminToken := "5c26a50841ff48237238bbdd021150f6a33a4199"
rt.DB.MustExec(`INSERT INTO api_apitoken(is_active, org_id, created, key, role_id, user_id) VALUES(TRUE, $1, NOW(), $2, 8, 1);`, testdata.Org1.ID, adminToken)
rt.DB.MustExec(`INSERT INTO api_apitoken(is_active, org_id, created, key, role_id, user_id) VALUES(TRUE, $1, NOW(), $2, $3, 1);`, testdata.Org1.ID, adminToken, testdata.AuthGroupIDs["Administrators"])

wg := &sync.WaitGroup{}
server := web.NewServer(ctx, rt, wg)
Expand Down
2 changes: 1 addition & 1 deletion web/surveyor/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestSurveyor(t *testing.T) {
defer server.Stop()

// insert an auth token for user 1 for org 1
rt.DB.MustExec(`INSERT INTO api_apitoken(is_active, key, created, org_id, role_id, user_id) VALUES(TRUE, 'sesame', NOW(), 1, 5, 1)`)
rt.DB.MustExec(`INSERT INTO api_apitoken(is_active, key, created, org_id, role_id, user_id) VALUES(TRUE, 'sesame', NOW(), $1, $2, 1)`, testdata.Org1.ID, testdata.AuthGroupIDs["Surveyors"])

type Assertion struct {
Query string
Expand Down

0 comments on commit d6ca9e8

Please sign in to comment.