-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_generator_test.go
79 lines (75 loc) · 4.18 KB
/
data_generator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package sqlsmith
import "testing"
func TestSQLSmith_DataGenerator(t *testing.T) {
ss := New()
schema := [][5]string{
{"community", "comments", "BASE TABLE", "id", "int(11)"},
{"community", "comments", "BASE TABLE", "owner", "varchar(255)"},
{"community", "comments", "BASE TABLE", "repo", "varchar(255)"},
{"community", "comments", "BASE TABLE", "comment_id", "int(11)"},
{"community", "comments", "BASE TABLE", "comment_type", "varchar(128)"},
{"community", "comments", "BASE TABLE", "pull_number", "int(11)"},
{"community", "comments", "BASE TABLE", "body", "text"},
{"community", "comments", "BASE TABLE", "user", "varchar(255)"},
{"community", "comments", "BASE TABLE", "url", "varchar(1023)"},
{"community", "comments", "BASE TABLE", "association", "varchar(255)"},
{"community", "comments", "BASE TABLE", "relation", "varchar(255)"},
{"community", "comments", "BASE TABLE", "created_at", "timestamp"},
{"community", "comments", "BASE TABLE", "updated_at", "timestamp"},
{"community", "picks", "BASE TABLE", "id", "int(11)"},
{"community", "picks", "BASE TABLE", "season", "int(11)"},
{"community", "picks", "BASE TABLE", "task_id", "int(11)"},
{"community", "picks", "BASE TABLE", "teamID", "int(11)"},
{"community", "picks", "BASE TABLE", "user", "varchar(255)"},
{"community", "picks", "BASE TABLE", "pull_number", "int(11)"},
{"community", "picks", "BASE TABLE", "status", "varchar(128)"},
{"community", "picks", "BASE TABLE", "created_at", "timestamp"},
{"community", "picks", "BASE TABLE", "updated_at", "timestamp"},
{"community", "picks", "BASE TABLE", "closed_at", "timestamp"},
{"community", "pulls", "BASE TABLE", "id", "int(11)"},
{"community", "pulls", "BASE TABLE", "owner", "varchar(255)"},
{"community", "pulls", "BASE TABLE", "repo", "varchar(255)"},
{"community", "pulls", "BASE TABLE", "pull_number", "int(11)"},
{"community", "pulls", "BASE TABLE", "title", "text"},
{"community", "pulls", "BASE TABLE", "body", "text"},
{"community", "pulls", "BASE TABLE", "user", "varchar(255)"},
{"community", "pulls", "BASE TABLE", "association", "varchar(255)"},
{"community", "pulls", "BASE TABLE", "relation", "varchar(255)"},
{"community", "pulls", "BASE TABLE", "label", "text"},
{"community", "pulls", "BASE TABLE", "status", "varchar(128)"},
{"community", "pulls", "BASE TABLE", "created_at", "timestamp"},
{"community", "pulls", "BASE TABLE", "updated_at", "timestamp"},
{"community", "pulls", "BASE TABLE", "closed_at", "timestamp"},
{"community", "pulls", "BASE TABLE", "merged_at", "timestamp"},
{"community", "tasks", "BASE TABLE", "id", "int(11)"},
{"community", "tasks", "BASE TABLE", "season", "int(11)"},
{"community", "tasks", "BASE TABLE", "complete_user", "varchar(255)"},
{"community", "tasks", "BASE TABLE", "complete_team", "int(11)"},
{"community", "tasks", "BASE TABLE", "owner", "varchar(255)"},
{"community", "tasks", "BASE TABLE", "repo", "varchar(255)"},
{"community", "tasks", "BASE TABLE", "title", "varchar(2047)"},
{"community", "tasks", "BASE TABLE", "issue_number", "int(11)"},
{"community", "tasks", "BASE TABLE", "pull_number", "int(11)"},
{"community", "tasks", "BASE TABLE", "level", "varchar(255)"},
{"community", "tasks", "BASE TABLE", "min_score", "int(11)"},
{"community", "tasks", "BASE TABLE", "score", "int(11)"},
{"community", "tasks", "BASE TABLE", "status", "varchar(255)"},
{"community", "tasks", "BASE TABLE", "created_at", "timestamp"},
{"community", "tasks", "BASE TABLE", "expired", "varchar(255)"},
{"community", "teams", "BASE TABLE", "id", "int(11)"},
{"community", "teams", "BASE TABLE", "season", "int(11)"},
{"community", "teams", "BASE TABLE", "name", "varchar(255)"},
{"community", "teams", "BASE TABLE", "issue_url", "varchar(1023)"},
{"community", "users", "BASE TABLE", "id", "int(11)"},
{"community", "users", "BASE TABLE", "season", "int(11)"},
{"community", "users", "BASE TABLE", "user", "varchar(255)"},
{"community", "users", "BASE TABLE", "team_id", "int(11)"},
}
ss.LoadSchema(schema)
ss.SetDB("community")
gen, _ := ss.GenData(10, 5)
for sqls := gen.Next(); len(sqls) != 0; sqls = gen.Next() {
t.Log(sqls)
}
// t.Log("rd string", ss.randString(ss.rd(100)))
}