MCPcopy Create free account
hub / github.com/AdRoll/baker / TestSQLiteNoTruncate

Function TestSQLiteNoTruncate

output/sqlite_test.go:185–214  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

183}
184
185func TestSQLiteNoTruncate(t *testing.T) {
186 // Tests that running the output twice doesn't truncate the table
187 // (E.g. if I want to run Baker and insert to existing files)
188 fn, rm := testutil.TempFile(t)
189 defer rm()
190
191 doOneRound(t, fn, false)
192 doOneRound(t, fn, false)
193
194 conn, err := sql.Open("sqlite3", fn)
195 if err != nil {
196 t.Fatalf("Cannot open output sqlite3 after running writer. %s", err)
197 }
198 defer conn.Close()
199
200 rows, err := conn.Query("SELECT field0, field1, field2 FROM lines")
201 if err != nil {
202 t.Fatalf("Cannot select data from sqlite3 after running writer. %s", err)
203 }
204 defer rows.Close()
205
206 row_id := 0
207 for rows.Next() {
208 row_id++
209 }
210
211 if row_id != 8 {
212 t.Fatalf("Expected 8 lines to be in sqlite3 file.")
213 }
214}
215
216func TestSQLiteTruncate(t *testing.T) {
217 // Test that, if I turn on truncating, the thing actually truncates.

Callers

nothing calls this directly

Calls 3

TempFileFunction · 0.92
doOneRoundFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected