InitTestCtxWithDB initializes a test context with the provided database and a temporary directory for all paths. Used when you need full control over database initialization (e.g. migration tests).
(t *testing.T, db *database.DB)
| 58 | // and a temporary directory for all paths. |
| 59 | // Used when you need full control over database initialization (e.g. migration tests). |
| 60 | func InitTestCtxWithDB(t *testing.T, db *database.DB) DnoteCtx { |
| 61 | paths := getDefaultTestPaths(t) |
| 62 | |
| 63 | if err := InitDnoteDirs(paths); err != nil { |
| 64 | t.Fatal(errors.Wrap(err, "creating test directories")) |
| 65 | } |
| 66 | |
| 67 | return DnoteCtx{ |
| 68 | DB: db, |
| 69 | Paths: paths, |
| 70 | Clock: clock.NewMock(), // Use a mock clock to test times |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // InitTestCtxWithFileDB initializes a test context with a file-based database |
| 75 | // at the expected path. |