InitTestCtx initializes a test context with an in-memory database and a temporary directory for all paths
(t *testing.T)
| 40 | // InitTestCtx initializes a test context with an in-memory database |
| 41 | // and a temporary directory for all paths |
| 42 | func InitTestCtx(t *testing.T) DnoteCtx { |
| 43 | paths := getDefaultTestPaths(t) |
| 44 | db := database.InitTestMemoryDB(t) |
| 45 | |
| 46 | if err := InitDnoteDirs(paths); err != nil { |
| 47 | t.Fatal(errors.Wrap(err, "creating test directories")) |
| 48 | } |
| 49 | |
| 50 | return DnoteCtx{ |
| 51 | DB: db, |
| 52 | Paths: paths, |
| 53 | Clock: clock.NewMock(), // Use a mock clock to test times |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // InitTestCtxWithDB initializes a test context with the provided database |
| 58 | // and a temporary directory for all paths. |