MCPcopy Create free account
hub / github.com/datasweet/datatable / TestToTable

Function TestToTable

export_test.go:56–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestToTable(t *testing.T) {
57 dt := sampleForExport(t)
58 out := dt.ToTable()
59 assert.NotNil(t, out)
60
61 expected := `[
62 ["Client ID", "Nom", "email", "ville"],
63 [1, "Aimée MARECHAL", "aime.marechal@example.com", "Paris"],
64 [2, "Esmée LEFORT", "esmee.lefort@example.com", "Lyon"],
65 [3, "Marine PREVOST", "m.prevost@example.com", "Lille"],
66 [4, "Luc ROLLAND", "lucrolland@example.com", "Marseille"]
67 ]`
68
69 bytes, err := json.Marshal(out)
70 assert.NoError(t, err)
71 assert.JSONEq(t, expected, string(bytes))
72
73 out2 := dt.ToTable(datatable.ExportHidden(true))
74 assert.NotNil(t, out2)
75
76 expected2 := `[
77 ["Client ID", "prenom", "nom", "Nom", "email", "ville"],
78 [1, "Aimée", "Marechal", "Aimée MARECHAL", "aime.marechal@example.com", "Paris"],
79 [2, "Esmée", "Lefort", "Esmée LEFORT", "esmee.lefort@example.com", "Lyon"],
80 [3, "Marine", "Prevost", "Marine PREVOST", "m.prevost@example.com", "Lille"],
81 [4, "Luc", "Rolland", "Luc ROLLAND", "lucrolland@example.com", "Marseille"]
82 ]`
83 bytes, err = json.Marshal(out2)
84 assert.NoError(t, err)
85 assert.JSONEq(t, expected2, string(bytes))
86}
87
88func TestToMap(t *testing.T) {
89 dt := sampleForExport(t)

Callers

nothing calls this directly

Calls 3

ExportHiddenFunction · 0.92
sampleForExportFunction · 0.85
ToTableMethod · 0.80

Tested by

no test coverage detected