MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestSQLAdminQuery

Function TestSQLAdminQuery

backend/tests/sql_query_test.go:18–193  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestSQLAdminQuery(t *testing.T) {
19 tests := []struct {
20 databaseName string
21 dbType storepb.Engine
22 prepareStatements string
23 query string
24 reset string
25 queryResult []*v1pb.QueryResult
26 resetResult []*v1pb.QueryResult
27 }{
28 {
29 databaseName: "Test1",
30 dbType: storepb.Engine_MYSQL,
31 prepareStatements: "CREATE TABLE tbl(id INT PRIMARY KEY, name VARCHAR(64), gender BIT(1), height BIT(8));",
32 query: "INSERT INTO Test1.tbl (id, name, gender, height) VALUES(1, 'Alice', B'0', B'01111111');",
33 reset: "DELETE FROM tbl;",
34 queryResult: []*v1pb.QueryResult{
35 {
36 ColumnNames: []string{"Affected Rows"},
37 ColumnTypeNames: []string{"INT"},
38 Rows: []*v1pb.QueryRow{
39 {
40 Values: []*v1pb.RowValue{
41 {Kind: &v1pb.RowValue_Int64Value{Int64Value: 1}},
42 },
43 },
44 },
45 Statement: "INSERT INTO Test1.tbl (id, name, gender, height) VALUES(1, 'Alice', B'0', B'01111111');",
46 RowsCount: 1,
47 },
48 },
49 resetResult: []*v1pb.QueryResult{
50 {
51 ColumnNames: []string{"Affected Rows"},
52 ColumnTypeNames: []string{"INT"},
53 Rows: []*v1pb.QueryRow{
54 {
55 Values: []*v1pb.RowValue{
56 {Kind: &v1pb.RowValue_Int64Value{Int64Value: 1}},
57 },
58 },
59 },
60 RowsCount: 1,
61 },
62 },
63 },
64 {
65 databaseName: "Test2",
66 dbType: storepb.Engine_POSTGRES,
67 prepareStatements: "CREATE TABLE tbl(id INT PRIMARY KEY, name VARCHAR(64), gender BIT(1), height BIT(8));",
68 query: "INSERT INTO tbl (id, name, gender, height) VALUES(1, 'Alice', B'0', B'01111111');",
69 reset: "DELETE FROM tbl;",
70 queryResult: []*v1pb.QueryResult{
71 {
72 ColumnNames: []string{"Affected Rows"},
73 ColumnTypeNames: []string{"INT"},
74 Rows: []*v1pb.QueryRow{
75 {

Callers

nothing calls this directly

Calls 14

CloseMethod · 0.95
createDatabaseMethod · 0.95
changeDatabaseMethod · 0.95
adminQueryMethod · 0.95
getMySQLContainerFunction · 0.85
getPgContainerFunction · 0.85
generateRandomStringFunction · 0.85
checkResultsFunction · 0.85
CloseMethod · 0.65
CreateInstanceMethod · 0.65
GetDatabaseMethod · 0.65

Tested by

no test coverage detected