MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestGetSQLStatementPrefix

Function TestGetSQLStatementPrefix

backend/component/export/export_test.go:17–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestGetSQLStatementPrefix(t *testing.T) {
18 tests := []struct {
19 engine storepb.Engine
20 resourceList []base.SchemaResource
21 columnNames []string
22 want string
23 }{
24 {
25 engine: storepb.Engine_MYSQL,
26 resourceList: nil,
27 columnNames: []string{"a"},
28 want: "INSERT INTO `<table_name>` (`a`) VALUES (",
29 },
30 {
31 engine: storepb.Engine_MYSQL,
32 resourceList: []base.SchemaResource{{Database: "db1", Schema: "", Table: "table1"}},
33 columnNames: []string{"a", "b"},
34 want: "INSERT INTO `table1` (`a`,`b`) VALUES (",
35 },
36 {
37 engine: storepb.Engine_TIDB,
38 resourceList: []base.SchemaResource{{Database: "db1", Schema: "", Table: "cbt_plans"}},
39 columnNames: []string{"id", "app_code", "locale"},
40 want: "INSERT INTO `cbt_plans` (`id`,`app_code`,`locale`) VALUES (",
41 },
42 {
43 engine: storepb.Engine_POSTGRES,
44 resourceList: nil,
45 columnNames: []string{"a"},
46 want: "INSERT INTO \"<table_name>\" (\"a\") VALUES (",
47 },
48 {
49 engine: storepb.Engine_POSTGRES,
50 resourceList: []base.SchemaResource{{Database: "db1", Schema: "", Table: "table1"}},
51 columnNames: []string{"a"},
52 want: "INSERT INTO \"table1\" (\"a\") VALUES (",
53 },
54 {
55 engine: storepb.Engine_POSTGRES,
56 resourceList: []base.SchemaResource{{Database: "db1", Schema: "schema1", Table: "table1"}},
57 columnNames: []string{"a"},
58 want: "INSERT INTO \"schema1\".\"table1\" (\"a\") VALUES (",
59 },
60 }
61 a := assert.New(t)
62
63 for _, test := range tests {
64 got, err := SQLStatementPrefix(test.engine, test.resourceList, test.columnNames)
65 a.NoError(err)
66 a.Equal(test.want, got)
67 }
68}
69
70func TestExportSQL(t *testing.T) {
71 tests := []struct {

Callers

nothing calls this directly

Calls 2

SQLStatementPrefixFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected