8
8
9
9
func TestCreate (t * testing.T ) {
10
10
t .Run ("should return correct sql string with basic columns and types" , func (t * testing.T ) {
11
- sql , _ , err := bob .CreateTable ("users" ).Columns ("name" , "password" , "date" ).Types ("varchar(255)" , "text" , "date" ).ToSQL ()
11
+ sql , _ , err := bob .CreateTable ("users" ).Columns ("name" , "password" , "date" ).Types ("varchar(255)" , "text" , "date" ).ToSql ()
12
12
if err != nil {
13
13
t .Fatal (err .Error ())
14
14
}
@@ -24,7 +24,7 @@ func TestCreate(t *testing.T) {
24
24
Types ("uuid" , "varchar(255)" , "varchar(255)" , "text" , "date" ).
25
25
Primary ("id" ).
26
26
Unique ("email" ).
27
- ToSQL ()
27
+ ToSql ()
28
28
if err != nil {
29
29
t .Fatal (err .Error ())
30
30
}
@@ -35,7 +35,7 @@ func TestCreate(t *testing.T) {
35
35
})
36
36
37
37
t .Run ("should be able to have a schema name" , func (t * testing.T ) {
38
- sql , _ , err := bob .CreateTable ("users" ).WithSchema ("private" ).Columns ("name" , "password" , "date" ).Types ("varchar(255)" , "text" , "date" ).ToSQL ()
38
+ sql , _ , err := bob .CreateTable ("users" ).WithSchema ("private" ).Columns ("name" , "password" , "date" ).Types ("varchar(255)" , "text" , "date" ).ToSql ()
39
39
if err != nil {
40
40
t .Fatal (err .Error ())
41
41
}
@@ -49,35 +49,35 @@ func TestCreate(t *testing.T) {
49
49
_ , _ , err := bob .CreateTable ("users" ).
50
50
Columns ("id" , "name" , "email" , "password" , "date" ).
51
51
Types ("uuid" , "varchar(255)" , "varchar(255)" , "date" ).
52
- ToSQL ()
52
+ ToSql ()
53
53
if err .Error () != "columns and types should have equal length" {
54
54
t .Fatal ("should throw an error, it didn't:" , err .Error ())
55
55
}
56
56
})
57
57
58
58
t .Run ("should emit error on empty table name" , func (t * testing.T ) {
59
- _ , _ , err := bob .CreateTable ("" ).Columns ("name" ).Types ("text" ).ToSQL ()
59
+ _ , _ , err := bob .CreateTable ("" ).Columns ("name" ).Types ("text" ).ToSql ()
60
60
if err .Error () != "create statements must specify a table" {
61
61
t .Fatal ("should throw an error, it didn't:" , err .Error ())
62
62
}
63
63
})
64
64
65
65
t .Run ("should emit error for primary key not in columns" , func (t * testing.T ) {
66
- _ , _ , err := bob .CreateTable ("users" ).Columns ("name" ).Types ("text" ).Primary ("id" ).ToSQL ()
66
+ _ , _ , err := bob .CreateTable ("users" ).Columns ("name" ).Types ("text" ).Primary ("id" ).ToSql ()
67
67
if err .Error () != "supplied primary column name doesn't exists on columns" {
68
68
t .Fatal ("should throw an error, it didn't:" , err .Error ())
69
69
}
70
70
})
71
71
72
72
t .Run ("should emit error for unique key not in columns" , func (t * testing.T ) {
73
- _ , _ , err := bob .CreateTable ("users" ).Columns ("name" ).Types ("text" ).Unique ("id" ).ToSQL ()
73
+ _ , _ , err := bob .CreateTable ("users" ).Columns ("name" ).Types ("text" ).Unique ("id" ).ToSql ()
74
74
if err .Error () != "supplied unique column name doesn't exists on columns" {
75
75
t .Fatal ("should throw an error, it didn't:" , err .Error ())
76
76
}
77
77
})
78
78
79
79
t .Run ("should emit create if not exists" , func (t * testing.T ) {
80
- sql , _ , err := bob .CreateTableIfNotExists ("users" ).Columns ("name" ).Types ("text" ).ToSQL ()
80
+ sql , _ , err := bob .CreateTableIfNotExists ("users" ).Columns ("name" ).Types ("text" ).ToSql ()
81
81
if err != nil {
82
82
t .Fatal (err .Error ())
83
83
}
0 commit comments