(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestGetTable(t *testing.T) { |
| 13 | sqlList := [][]string{ |
| 14 | {"select * from a", "a"}, |
| 15 | {"select * FROM a", "a"}, |
| 16 | {"select * FROM a where 1=1", "a"}, |
| 17 | {"select version()", ""}, |
| 18 | {"SELECT * FROM users WHERE id = 1", "users"}, |
| 19 | {"select count(*) from orders", "orders"}, |
| 20 | {"FROM products select *", "products"}, // This actually extracts "products" |
| 21 | {"", ""}, // Empty SQL |
| 22 | } |
| 23 | for _, sql := range sqlList { |
| 24 | table := getTableName(sql[0]) |
| 25 | if table != sql[1] { |
| 26 | t.Errorf("table name error, sql: %s, getTableName: %s, expected: %s", sql[0], table, sql[1]) |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | func TestGetColumnTypeAndLen(t *testing.T) { |
| 32 | testCases := []struct { |
nothing calls this directly
no test coverage detected