Skip to content

Commit

Permalink
add delete test
Browse files Browse the repository at this point in the history
  • Loading branch information
oussama4 committed Nov 18, 2021
1 parent 10cd328 commit 374697b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions delete_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package sqlbuilder

import "testing"

func TestDelete(t *testing.T) {
cases := []struct {
query *DeleteBuilder
wantQuery string
args []interface{}
}{
{
query: DeleteFrom("products"),
wantQuery: "DELETE FROM products",
},
{
query: DeleteFrom("products").Where(Like("title", "%airpod%")),
wantQuery: "DELETE FROM products WHERE title LIKE $1",
args: []interface{}{"airpod"},
},
}

for _, c := range cases {
q, args := c.query.Query()
if q != c.wantQuery || len(c.args) != len(args) {
t.Errorf("want:\n %s\n got:\n %s\n", c.wantQuery, q)
}
}
}

0 comments on commit 374697b

Please sign in to comment.