|
1 | 1 | package mysql
|
2 | 2 |
|
3 |
| -import ( |
4 |
| - "testing" |
5 |
| - |
6 |
| - rulepkg "github.com/actiontech/sqle/sqle/driver/mysql/rule" |
7 |
| - "github.com/actiontech/sqle/sqle/driver/mysql/rule/ai" |
8 |
| -) |
9 |
| - |
10 |
| -// ==== Rule test code start ==== |
11 |
| -func TestRuleSQLE00023(t *testing.T) { |
12 |
| - ruleName := ai.SQLE00023 |
13 |
| - rule := rulepkg.AIRuleHandlerMap[ruleName].Rule |
14 |
| - ruleParams := []interface{}{2} |
15 |
| - //create table, no primary key |
16 |
| - runSingleRuleInspectCase(rule, t, "create table, no primary key", DefaultMysqlInspect(), ` |
17 |
| - CREATE TABLE if not exists exist_db.not_exist_tb_1 ( |
18 |
| - id bigint unsigned NOT NULL AUTO_INCREMENT COMMENT "unit test" |
19 |
| - ); |
20 |
| - `, newTestResult()) |
21 |
| - |
22 |
| - //create table, with primary key, fewer than expected number of columns |
23 |
| - runSingleRuleInspectCase(rule, t, "create table, with primary key, fewer than expected number of columns", DefaultMysqlInspect(), ` |
24 |
| - CREATE TABLE if not exists exist_db.not_exist_tb_1 ( |
25 |
| - id bigint unsigned NOT NULL AUTO_INCREMENT COMMENT "unit test", |
26 |
| - id2 bigint, |
27 |
| - PRIMARY KEY (id, id2) |
28 |
| - ); |
29 |
| - `, newTestResult()) |
30 |
| - |
31 |
| - //create table, with primary key, more than expected number of columns |
32 |
| - runSingleRuleInspectCase(rule, t, "create table, with primary key, fewer than expected number of columns", DefaultMysqlInspect(), ` |
33 |
| - CREATE TABLE if not exists exist_db.not_exist_tb_1 ( |
34 |
| - id bigint unsigned NOT NULL AUTO_INCREMENT COMMENT "unit test", |
35 |
| - a int, |
36 |
| - b int, |
37 |
| - PRIMARY KEY (id, a, b) |
38 |
| - ); |
39 |
| - `, newTestResult().addResult(ruleName, ruleParams...)) |
40 |
| - |
41 |
| - //alter table, no primary key |
42 |
| - runSingleRuleInspectCase(rule, t, "alter table, no primary key", DefaultMysqlInspect(), ` |
43 |
| - ALTER TABLE exist_db.exist_tb_3 ADD COLUMN a int NOT NULL COMMENT "unit test"; |
44 |
| - `, newTestResult()) |
45 |
| - |
46 |
| - //alter table, with primary key, fewer than expected number of columns |
47 |
| - runSingleRuleInspectCase(rule, t, "alter table, with primary key, fewer than expected number of columns", DefaultMysqlInspect(), ` |
48 |
| - ALTER TABLE exist_db.exist_tb_3 ADD CONSTRAINT PK_c PRIMARY KEY (id, v1); |
49 |
| - `, newTestResult()) |
50 |
| - |
51 |
| - //alter table, with primary key, more than expected number of columns |
52 |
| - runSingleRuleInspectCase(rule, t, "alter table, with primary key, more than expected number of columns", DefaultMysqlInspect(), ` |
53 |
| - ALTER TABLE exist_db.exist_tb_3 ADD CONSTRAINT PK_c PRIMARY KEY (id, v1, v2); |
54 |
| - `, newTestResult().addResult(ruleName, ruleParams...)) |
55 |
| -} |
56 |
| - |
57 |
| -// ==== Rule test code end ==== |
| 3 | +//import ( |
| 4 | +// "testing" |
| 5 | +// |
| 6 | +// rulepkg "github.com/actiontech/sqle/sqle/driver/mysql/rule" |
| 7 | +// "github.com/actiontech/sqle/sqle/driver/mysql/rule/ai" |
| 8 | +//) |
| 9 | +// |
| 10 | +//// ==== Rule test code start ==== |
| 11 | +//func TestRuleSQLE00023(t *testing.T) { |
| 12 | +// ruleName := ai.SQLE00023 |
| 13 | +// rule := rulepkg.AIRuleHandlerMap[ruleName].Rule |
| 14 | +// ruleParams := []interface{}{2} |
| 15 | +// //create table, no primary key |
| 16 | +// runSingleRuleInspectCase(rule, t, "create table, no primary key", DefaultMysqlInspect(), ` |
| 17 | +// CREATE TABLE if not exists exist_db.not_exist_tb_1 ( |
| 18 | +// id bigint unsigned NOT NULL AUTO_INCREMENT COMMENT "unit test" |
| 19 | +// ); |
| 20 | +// `, newTestResult()) |
| 21 | +// |
| 22 | +// //create table, with primary key, fewer than expected number of columns |
| 23 | +// runSingleRuleInspectCase(rule, t, "create table, with primary key, fewer than expected number of columns", DefaultMysqlInspect(), ` |
| 24 | +// CREATE TABLE if not exists exist_db.not_exist_tb_1 ( |
| 25 | +// id bigint unsigned NOT NULL AUTO_INCREMENT COMMENT "unit test", |
| 26 | +// id2 bigint, |
| 27 | +// PRIMARY KEY (id, id2) |
| 28 | +// ); |
| 29 | +// `, newTestResult()) |
| 30 | +// |
| 31 | +// //create table, with primary key, more than expected number of columns |
| 32 | +// runSingleRuleInspectCase(rule, t, "create table, with primary key, fewer than expected number of columns", DefaultMysqlInspect(), ` |
| 33 | +// CREATE TABLE if not exists exist_db.not_exist_tb_1 ( |
| 34 | +// id bigint unsigned NOT NULL AUTO_INCREMENT COMMENT "unit test", |
| 35 | +// a int, |
| 36 | +// b int, |
| 37 | +// PRIMARY KEY (id, a, b) |
| 38 | +// ); |
| 39 | +// `, newTestResult().addResult(ruleName, ruleParams...)) |
| 40 | +// |
| 41 | +// //alter table, no primary key |
| 42 | +// runSingleRuleInspectCase(rule, t, "alter table, no primary key", DefaultMysqlInspect(), ` |
| 43 | +// ALTER TABLE exist_db.exist_tb_3 ADD COLUMN a int NOT NULL COMMENT "unit test"; |
| 44 | +// `, newTestResult()) |
| 45 | +// |
| 46 | +// //alter table, with primary key, fewer than expected number of columns |
| 47 | +// runSingleRuleInspectCase(rule, t, "alter table, with primary key, fewer than expected number of columns", DefaultMysqlInspect(), ` |
| 48 | +// ALTER TABLE exist_db.exist_tb_3 ADD CONSTRAINT PK_c PRIMARY KEY (id, v1); |
| 49 | +// `, newTestResult()) |
| 50 | +// |
| 51 | +// //alter table, with primary key, more than expected number of columns |
| 52 | +// runSingleRuleInspectCase(rule, t, "alter table, with primary key, more than expected number of columns", DefaultMysqlInspect(), ` |
| 53 | +// ALTER TABLE exist_db.exist_tb_3 ADD CONSTRAINT PK_c PRIMARY KEY (id, v1, v2); |
| 54 | +// `, newTestResult().addResult(ruleName, ruleParams...)) |
| 55 | +//} |
| 56 | +// |
| 57 | +//// ==== Rule test code end ==== |
0 commit comments