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

Function TestToSchema

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

Source from the content-addressed store, hash-verified

117}
118
119func TestToSchema(t *testing.T) {
120 dt := sampleForExport(t)
121 schema := dt.ToSchema()
122 assert.NotNil(t, schema)
123 assert.Equal(t, "Customers", schema.Name)
124 assert.Equal(t, []datatable.SchemaColumn{
125 datatable.SchemaColumn{"Client ID", "NullInt"},
126 datatable.SchemaColumn{"Nom", "NullString"},
127 datatable.SchemaColumn{"email", "NullString"},
128 datatable.SchemaColumn{"ville", "NullString"},
129 }, schema.Columns)
130 assert.Len(t, schema.Rows, 4)
131 assert.Equal(t, []interface{}{1, "Aimée MARECHAL", "aime.marechal@example.com", "Paris"}, schema.Rows[0])
132 assert.Equal(t, []interface{}{2, "Esmée LEFORT", "esmee.lefort@example.com", "Lyon"}, schema.Rows[1])
133 assert.Equal(t, []interface{}{3, "Marine PREVOST", "m.prevost@example.com", "Lille"}, schema.Rows[2])
134 assert.Equal(t, []interface{}{4, "Luc ROLLAND", "lucrolland@example.com", "Marseille"}, schema.Rows[3])
135
136 schema2 := dt.ToSchema(datatable.ExportHidden(true))
137 assert.NotNil(t, schema2)
138 assert.Equal(t, "Customers", schema2.Name)
139 assert.Equal(t, []datatable.SchemaColumn{
140 datatable.SchemaColumn{"Client ID", "NullInt"},
141 datatable.SchemaColumn{"prenom", "NullString"},
142 datatable.SchemaColumn{"nom", "NullString"},
143 datatable.SchemaColumn{"Nom", "NullString"},
144 datatable.SchemaColumn{"email", "NullString"},
145 datatable.SchemaColumn{"ville", "NullString"},
146 }, schema2.Columns)
147 assert.Len(t, schema2.Rows, 4)
148 assert.Equal(t, []interface{}{1, "Aimée", "Marechal", "Aimée MARECHAL", "aime.marechal@example.com", "Paris"}, schema2.Rows[0])
149 assert.Equal(t, []interface{}{2, "Esmée", "Lefort", "Esmée LEFORT", "esmee.lefort@example.com", "Lyon"}, schema2.Rows[1])
150 assert.Equal(t, []interface{}{3, "Marine", "Prevost", "Marine PREVOST", "m.prevost@example.com", "Lille"}, schema2.Rows[2])
151 assert.Equal(t, []interface{}{4, "Luc", "Rolland", "Luc ROLLAND", "lucrolland@example.com", "Marseille"}, schema2.Rows[3])
152}

Callers

nothing calls this directly

Calls 4

ExportHiddenFunction · 0.92
sampleForExportFunction · 0.85
ToSchemaMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected