(t *testing.T)
| 38 | var localManager *Manager |
| 39 | |
| 40 | func 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 | |
| 70 | func (se *SessionExecutor) forTest(sql string, ctx *util.RequestContext) error { |
| 71 | _, err := se.doQuery(ctx, sql) |
nothing calls this directly
no test coverage detected