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

Function InitTestFileDBRaw

pkg/cli/database/testutils.go:70–82  ·  view source on GitHub ↗

InitTestFileDBRaw initializes a file-based test database at the specified path with the default schema.

(t *testing.T, dbPath string)

Source from the content-addressed store, hash-verified

68
69// InitTestFileDBRaw initializes a file-based test database at the specified path with the default schema.
70func InitTestFileDBRaw(t *testing.T, dbPath string) *DB {
71 db, err := Open(dbPath)
72 if err != nil {
73 t.Fatal(errors.Wrap(err, "opening database"))
74 }
75
76 if _, err := db.Exec(defaultSchemaSQL); err != nil {
77 t.Fatal(errors.Wrap(err, "running schema sql"))
78 }
79
80 t.Cleanup(func() { db.Close() })
81 return db
82}
83
84// InitTestMemoryDBRaw initializes an in-memory test database without marking migrations complete.
85// If schemaPath is empty, uses the default schema. Used for migration testing.

Callers 1

InitTestFileDBFunction · 0.85

Calls 3

OpenFunction · 0.70
ExecMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected