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

Function TestToMap

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

Source from the content-addressed store, hash-verified

86}
87
88func TestToMap(t *testing.T) {
89 dt := sampleForExport(t)
90 out := dt.ToMap()
91 assert.NotNil(t, out)
92
93 expected := `[
94 { "Client ID":1, "Nom":"Aimée MARECHAL", "email":"aime.marechal@example.com", "ville":"Paris" },
95 { "Client ID":2, "Nom":"Esmée LEFORT", "email":"esmee.lefort@example.com", "ville":"Lyon" },
96 { "Client ID":3, "Nom":"Marine PREVOST", "email":"m.prevost@example.com", "ville":"Lille" },
97 { "Client ID":4, "Nom":"Luc ROLLAND", "email":"lucrolland@example.com", "ville":"Marseille" }
98]`
99
100 bytes, err := json.Marshal(out)
101 assert.NoError(t, err)
102 assert.JSONEq(t, expected, string(bytes))
103
104 out2 := dt.ToMap(datatable.ExportHidden(true))
105 assert.NotNil(t, out2)
106
107 expected2 := `[
108 { "Client ID":1, "prenom": "Aimée", "nom": "Marechal", "Nom":"Aimée MARECHAL", "email":"aime.marechal@example.com", "ville":"Paris" },
109 { "Client ID":2, "prenom": "Esmée", "nom": "Lefort", "Nom":"Esmée LEFORT", "email":"esmee.lefort@example.com", "ville":"Lyon" },
110 { "Client ID":3, "prenom": "Marine", "nom": "Prevost", "Nom":"Marine PREVOST", "email":"m.prevost@example.com", "ville":"Lille" },
111 { "Client ID":4, "prenom": "Luc", "nom": "Rolland", "Nom":"Luc ROLLAND", "email":"lucrolland@example.com", "ville":"Marseille" }
112]`
113
114 bytes, err = json.Marshal(out2)
115 assert.NoError(t, err)
116 assert.JSONEq(t, expected2, string(bytes))
117}
118
119func TestToSchema(t *testing.T) {
120 dt := sampleForExport(t)

Callers

nothing calls this directly

Calls 3

ExportHiddenFunction · 0.92
sampleForExportFunction · 0.85
ToMapMethod · 0.80

Tested by

no test coverage detected