MCPcopy
hub / github.com/apache/devlake / TestExampleCsvFile

Function TestExampleCsvFile

backend/helpers/pluginhelper/csv_file_test.go:26–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func 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
44func TestWrongCsvPath(t *testing.T) {
45 tmpPath := t.TempDir()

Callers

nothing calls this directly

Calls 7

WriteMethod · 0.95
CloseMethod · 0.95
CloseMethod · 0.95
HasNextMethod · 0.95
FetchMethod · 0.95
NewCsvFileWriterFunction · 0.85
NewCsvFileIteratorFunction · 0.85

Tested by

no test coverage detected