summaryrefslogtreecommitdiff
path: root/testrig/db.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-08-10 13:32:39 +0200
committerLibravatar GitHub <noreply@github.com>2021-08-10 13:32:39 +0200
commit0f2de6394a1c52d47e326bb7d7d129a217ae4f6f (patch)
treee2709bdbbbbcf5e12d6da62b653b67f1789ab1c5 /testrig/db.go
parentFrodo swaggins (#126) (diff)
downloadgotosocial-0f2de6394a1c52d47e326bb7d7d129a217ae4f6f.tar.xz
Dereference remote replies (#132)
* decided where to put reply dereferencing * fiddling with dereferencing threads * further adventures * tidy up some stuff * move dereferencing functionality * a bunch of refactoring * go fmt * more refactoring * bleep bloop * docs and linting * start implementing replies collection on gts side * fiddling around * allow dereferencing our replies * lint, fmt
Diffstat (limited to 'testrig/db.go')
-rw-r--r--testrig/db.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/testrig/db.go b/testrig/db.go
index 01cf93934..fe38c3164 100644
--- a/testrig/db.go
+++ b/testrig/db.go
@@ -65,7 +65,14 @@ func NewTestDB() db.DB {
}
// StandardDBSetup populates a given db with all the necessary tables/models for perfoming tests.
-func StandardDBSetup(db db.DB) {
+//
+// The accounts parameter is provided in case the db should be populated with a certain set of accounts.
+// If accounts is nil, then the standard test accounts will be used.
+//
+// When testing http signatures, you should pass into this function the same accounts map that you generated
+// signatures with, otherwise this function will randomly generate new keys for accounts and signature
+// verification will fail.
+func StandardDBSetup(db db.DB, accounts map[string]*gtsmodel.Account) {
for _, m := range testModels {
if err := db.CreateTable(m); err != nil {
panic(err)
@@ -96,9 +103,17 @@ func StandardDBSetup(db db.DB) {
}
}
- for _, v := range NewTestAccounts() {
- if err := db.Put(v); err != nil {
- panic(err)
+ if accounts == nil {
+ for _, v := range NewTestAccounts() {
+ if err := db.Put(v); err != nil {
+ panic(err)
+ }
+ }
+ } else {
+ for _, v := range accounts {
+ if err := db.Put(v); err != nil {
+ panic(err)
+ }
}
}