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

Function sampleForExport

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

Source from the content-addressed store, hash-verified

9)
10
11func sampleForExport(t *testing.T) *datatable.DataTable {
12 customers := datatable.New("Customers")
13 err := customers.AddColumn("id", datatable.Int)
14 assert.NoError(t, err)
15
16 err = customers.AddColumn("prenom", datatable.String)
17 assert.NoError(t, err)
18
19 err = customers.AddColumn("nom", datatable.String)
20 assert.NoError(t, err)
21 //dc.Hidden(true)
22
23 err = customers.AddColumn("expr_nom", datatable.String, datatable.Expr("`prenom` ~ ' ' ~ UPPER(`nom`)"))
24 assert.NoError(t, err)
25 //dc.Label("nom")
26
27 err = customers.AddColumn("email", datatable.String)
28 assert.NoError(t, err)
29
30 err = customers.AddColumn("ville", datatable.String)
31 assert.NoError(t, err)
32
33 customers.AppendRow(1, "Aimée", "Marechal", nil, "aime.marechal@example.com", "Paris")
34 customers.AppendRow(2, "Esmée", "Lefort", nil, "esmee.lefort@example.com", "Lyon")
35 customers.AppendRow(3, "Marine", "Prevost", nil, "m.prevost@example.com", "Lille")
36 customers.AppendRow(4, "Luc", "Rolland", nil, "lucrolland@example.com", "Marseille")
37
38 // Change structs
39 assert.NoError(t, customers.RenameColumn("id", "Client ID"))
40 customers.HideColumn("prenom")
41 customers.HideColumn("nom")
42 assert.Error(t, customers.RenameColumn("expr_nom", "nom"))
43 assert.NoError(t, customers.RenameColumn("expr_nom", "Nom"))
44
45 checkTable(t, customers,
46 "Client ID", "Nom", "email", "ville",
47 1, "Aimée MARECHAL", "aime.marechal@example.com", "Paris",
48 2, "Esmée LEFORT", "esmee.lefort@example.com", "Lyon",
49 3, "Marine PREVOST", "m.prevost@example.com", "Lille",
50 4, "Luc ROLLAND", "lucrolland@example.com", "Marseille",
51 )
52
53 return customers
54}
55
56func TestToTable(t *testing.T) {
57 dt := sampleForExport(t)

Callers 3

TestToTableFunction · 0.85
TestToMapFunction · 0.85
TestToSchemaFunction · 0.85

Calls 7

NewFunction · 0.92
ExprFunction · 0.92
checkTableFunction · 0.85
AddColumnMethod · 0.80
AppendRowMethod · 0.80
RenameColumnMethod · 0.80
HideColumnMethod · 0.80

Tested by

no test coverage detected