MCPcopy
hub / github.com/dnote/dnote / InitTestCtx

Function InitTestCtx

pkg/cli/context/testutils.go:42–55  ·  view source on GitHub ↗

InitTestCtx initializes a test context with an in-memory database and a temporary directory for all paths

(t *testing.T)

Source from the content-addressed store, hash-verified

40// InitTestCtx initializes a test context with an in-memory database
41// and a temporary directory for all paths
42func 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.

Callers 6

TestSendBooksFunction · 0.92
TestSendBooks_isBehindFunction · 0.92
TestSendNotesFunction · 0.92
TestSendNotes_addedOnFunction · 0.92
TestSendNotes_isBehindFunction · 0.92
TestGetTmpContentPathFunction · 0.92

Calls 4

InitTestMemoryDBFunction · 0.92
NewMockFunction · 0.92
getDefaultTestPathsFunction · 0.85
InitDnoteDirsFunction · 0.85

Tested by 6

TestSendBooksFunction · 0.74
TestSendBooks_isBehindFunction · 0.74
TestSendNotesFunction · 0.74
TestSendNotes_addedOnFunction · 0.74
TestSendNotes_isBehindFunction · 0.74
TestGetTmpContentPathFunction · 0.74