(t *testing.T, raw bool, path string, truncate bool)
| 14 | ) |
| 15 | |
| 16 | func makeWriter(t *testing.T, raw bool, path string, truncate bool) baker.Output { |
| 17 | t.Helper() |
| 18 | |
| 19 | var cfg interface{} |
| 20 | |
| 21 | if raw { |
| 22 | cfg = &SQLiteRawWriterConfig{ |
| 23 | PathString: path, |
| 24 | TableName: "lines", |
| 25 | Clear: truncate, |
| 26 | RecordBlobName: "raw_record", |
| 27 | } |
| 28 | } else { |
| 29 | cfg = &SQLiteWriterConfig{ |
| 30 | PathString: path, |
| 31 | TableName: "lines", |
| 32 | Clear: truncate, |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | fieldByName := func(name string) (baker.FieldIndex, bool) { |
| 37 | switch name { |
| 38 | case "field0": |
| 39 | return 0, true |
| 40 | case "field1": |
| 41 | return 1, true |
| 42 | case "field2": |
| 43 | return 2, true |
| 44 | } |
| 45 | return 0, false |
| 46 | } |
| 47 | |
| 48 | fieldNames := []string{"field0", "field1", "field2"} |
| 49 | |
| 50 | params := baker.OutputParams{ |
| 51 | Fields: []baker.FieldIndex{0, 1, 2}, |
| 52 | Index: 0, |
| 53 | ComponentParams: baker.ComponentParams{ |
| 54 | DecodedConfig: cfg, |
| 55 | FieldByName: fieldByName, |
| 56 | FieldNames: fieldNames, |
| 57 | }, |
| 58 | } |
| 59 | writer, err := newSQLiteWriter(raw)(params) |
| 60 | if err != nil { |
| 61 | t.Fatalf("SQLite writer creation failed: %s", err) |
| 62 | } |
| 63 | return writer |
| 64 | } |
| 65 | |
| 66 | // Just check that creating an sqlite writer does not crash. |
| 67 | func TestSQLiteNewSQLiteWriter(t *testing.T) { makeWriter(t, false, ":memory:", false) } |
no outgoing calls
no test coverage detected