MCPcopy Index your code
hub / github.com/dnote/dnote / InitTestCtxWithDB

Function InitTestCtxWithDB

pkg/cli/context/testutils.go:60–72  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

58// and a temporary directory for all paths.
59// Used when you need full control over database initialization (e.g. migration tests).
60func 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.

Callers 15

TestExecute_bump_schemaFunction · 0.92
TestRun_nonfreshFunction · 0.92
TestRun_freshFunction · 0.92
TestRun_up_to_dateFunction · 0.92
TestLocalMigration1Function · 0.92
TestLocalMigration2Function · 0.92
TestLocalMigration3Function · 0.92
TestLocalMigration4Function · 0.92
TestLocalMigration5Function · 0.92
TestLocalMigration6Function · 0.92

Calls 3

NewMockFunction · 0.92
getDefaultTestPathsFunction · 0.85
InitDnoteDirsFunction · 0.85

Tested by 15

TestExecute_bump_schemaFunction · 0.74
TestRun_nonfreshFunction · 0.74
TestRun_freshFunction · 0.74
TestRun_up_to_dateFunction · 0.74
TestLocalMigration1Function · 0.74
TestLocalMigration2Function · 0.74
TestLocalMigration3Function · 0.74
TestLocalMigration4Function · 0.74
TestLocalMigration5Function · 0.74
TestLocalMigration6Function · 0.74