-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdelete_test.go
More file actions
41 lines (34 loc) · 772 Bytes
/
delete_test.go
File metadata and controls
41 lines (34 loc) · 772 Bytes
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
package sqlbuilder
import (
"reflect"
"testing"
)
func TestDelete(t *testing.T) {
query, args := Delete().
Dialect(MySQL).
From("customers").
Build()
expectedQuery := "DELETE FROM customers"
if query != expectedQuery {
t.Errorf("bad query: %s", query)
}
if args != nil {
t.Errorf("bad args: %v", args)
}
}
func TestDeleteWhere(t *testing.T) {
query, args := Delete().
Dialect(MySQL).
From("customers").
Where("name = ?", "John").
Where("phone = ?", "555").
Build()
expectedQuery := "DELETE FROM customers WHERE (name = ?) AND (phone = ?)"
if query != expectedQuery {
t.Errorf("bad query: %s", query)
}
expectedArgs := []interface{}{"John", "555"}
if !reflect.DeepEqual(args, expectedArgs) {
t.Errorf("bad args: %v", args)
}
}