add delete query
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package simql
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alecthomas/assert/v2"
|
||||
)
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
type TestCase struct {
|
||||
In *DeleteQuery
|
||||
Args []any
|
||||
String string
|
||||
}
|
||||
|
||||
testCases := []TestCase{
|
||||
{
|
||||
In: Delete("customer"),
|
||||
String: "delete from customer",
|
||||
},
|
||||
{
|
||||
In: Delete("customer as c"),
|
||||
String: "delete from customer as c",
|
||||
},
|
||||
{
|
||||
In: Delete("customer as c"),
|
||||
String: "select c.id, c.name from customer as c",
|
||||
},
|
||||
{
|
||||
In: Delete("customer").Where("id = ?", 1234),
|
||||
Args: []any{1234},
|
||||
String: "delete from customer where id = ?",
|
||||
},
|
||||
{
|
||||
In: Delete("customer as c").Where("c.id = ?", 1234),
|
||||
Args: []any{1234},
|
||||
String: "delete from customer as c where c.id = ?",
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.String, func(t *testing.T) {
|
||||
assert.Equal(t, testCase.Args, testCase.In.Args(), "collected arguments incorrectly")
|
||||
assert.Equal(t, testCase.String, testCase.In.String(), "stringified incorrectly")
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user