package mdb import ( "testing" "time" ) type TestDB struct { *Database Users Users UserData UserData } func NewTestDBPrimary(t *testing.T, rootDir string) TestDB { db := New(Config{ RootDir: rootDir, Primary: true, NetTimeout: 8 * time.Second, ReplicationPSK: "123", }) testDB := TestDB{ Database: db, Users: NewUserCollection(db), UserData: NewUserDataCollection(db), } if err := testDB.Open(); err != nil { t.Fatal(err) } return testDB } func NewTestSecondaryDB(t *testing.T, rootDir, primaryURL string) TestDB { db := New(Config{ RootDir: rootDir, PrimaryEndpoint: primaryURL, NetTimeout: 8 * time.Second, ReplicationPSK: "123", }) testDB := TestDB{ Database: db, Users: NewUserCollection(db), UserData: NewUserDataCollection(db), } if err := testDB.Open(); err != nil { t.Fatal(err) } return testDB }