MCPcopy
hub / github.com/benbjohnson/litestream / createTestSQLiteDB

Function createTestSQLiteDB

replica_test.go:1900–1918  ·  view source on GitHub ↗

createTestSQLiteDB creates a minimal valid SQLite database for testing.

(t *testing.T)

Source from the content-addressed store, hash-verified

1898
1899// createTestSQLiteDB creates a minimal valid SQLite database for testing.
1900func createTestSQLiteDB(t *testing.T) []byte {
1901 t.Helper()
1902
1903 tmpPath := t.TempDir() + "/test.db"
1904 sqldb := testingutil.MustOpenSQLDB(t, tmpPath)
1905 if _, err := sqldb.Exec(`CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)`); err != nil {
1906 t.Fatal(err)
1907 }
1908 if _, err := sqldb.Exec(`INSERT INTO test (value) VALUES ('hello')`); err != nil {
1909 t.Fatal(err)
1910 }
1911 testingutil.MustCloseSQLDB(t, sqldb)
1912
1913 data, err := os.ReadFile(tmpPath)
1914 if err != nil {
1915 t.Fatal(err)
1916 }
1917 return data
1918}
1919
1920func createTestWALData(t *testing.T, dbData []byte) []byte {
1921 t.Helper()

Callers 2

TestReplica_RestoreV3Function · 0.85

Calls 2

MustOpenSQLDBFunction · 0.92
MustCloseSQLDBFunction · 0.92

Tested by

no test coverage detected