MCPcopy
hub / github.com/XiaoMi/Gaea / TestGetVariableExprResult

Function TestGetVariableExprResult

proxy/server/executor_test.go:40–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38var localManager *Manager
39
40func TestGetVariableExprResult(t *testing.T) {
41 tests := []struct {
42 variable []string
43 expect string
44 }{
45 {[]string{"ON", "on", "'on'", "`on`"}, "on"},
46 {[]string{"OFF", "off", "'off'", "`off`"}, "off"},
47 {[]string{"1", "'1'", "`1`"}, "1"},
48 {[]string{"0", "'0'", "`0`"}, "0"},
49 }
50 for _, test := range tests {
51 t.Run(test.expect, func(t *testing.T) {
52 for _, v := range test.variable {
53 sql := fmt.Sprintf("set autocommit = %s", v)
54 s, err := parser.ParseSQL(sql)
55 if err != nil {
56 t.Fatal(err)
57 }
58 stmt := s.(*ast.SetStmt)
59 for _, v := range stmt.Variables {
60 actual := getVariableExprResult(v.Value)
61 if actual != test.expect {
62 t.Errorf("not equal, fromSlave: %v, actual: %v", test.expect, actual)
63 }
64 }
65 }
66 })
67 }
68}
69
70func (se *SessionExecutor) forTest(sql string, ctx *util.RequestContext) error {
71 _, err := se.doQuery(ctx, sql)

Callers

nothing calls this directly

Calls 5

ParseSQLFunction · 0.92
getVariableExprResultFunction · 0.85
FatalMethod · 0.65
ErrorfMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected