-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
drop_test.go
62 lines (51 loc) · 1.21 KB
/
drop_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
package bob_test
import (
"testing"
"github.com/aldy505/bob"
)
func TestDrop_Regular(t *testing.T) {
sql, _, err := bob.DropTable("users").ToSql()
if err != nil {
t.Error(err)
}
result := "DROP TABLE \"users\";"
if sql != result {
t.Error("sql is not the same as result: ", sql)
}
}
func TestDrop_IfExists(t *testing.T) {
sql, _, err := bob.DropTableIfExists("users").ToSql()
if err != nil {
t.Error(err)
}
result := "DROP TABLE IF EXISTS \"users\";"
if sql != result {
t.Error("sql is not the same as result: ", sql)
}
}
func TestDrop_Cascade(t *testing.T) {
sql, _, err := bob.DropTable("users").Cascade().ToSql()
if err != nil {
t.Error(err)
}
result := "DROP TABLE \"users\" CASCADE;"
if sql != result {
t.Error("sql is not the same as result: ", sql)
}
}
func TestDrop_Restrict(t *testing.T) {
sql, _, err := bob.DropTable("users").Restrict().ToSql()
if err != nil {
t.Error(err)
}
result := "DROP TABLE \"users\" RESTRICT;"
if sql != result {
t.Error("sql is not the same as result: ", sql)
}
}
func TestDrop_ErrNoTable(t *testing.T) {
_, _, err := bob.DropTableIfExists("").ToSql()
if err == nil && err.Error() != "drop statement must specify a table" {
t.Error(err)
}
}