(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestExampleCsvFile(t *testing.T) { |
| 27 | tmpPath := t.TempDir() |
| 28 | filename := fmt.Sprintf(`%s/foobar.csv`, tmpPath) |
| 29 | println(filename) |
| 30 | |
| 31 | writer, _ := NewCsvFileWriter(filename, []string{"id", "name", "json", "created_at"}) |
| 32 | writer.Write([]string{"123", "foobar", `{"url": "https://example.com"}`, "2022-05-05 09:56:43.438000000"}) |
| 33 | writer.Close() |
| 34 | |
| 35 | iter, _ := NewCsvFileIterator(filename) |
| 36 | defer iter.Close() |
| 37 | for iter.HasNext() { |
| 38 | row := iter.Fetch() |
| 39 | assert.Equal(t, row["name"], "foobar", "name not equal") |
| 40 | assert.Equal(t, row["json"], `{"url": "https://example.com"}`, "json not equal") |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | func TestWrongCsvPath(t *testing.T) { |
| 45 | tmpPath := t.TempDir() |
nothing calls this directly
no test coverage detected