48 lines
1018 B
Go
48 lines
1018 B
Go
package sqimple
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/alecthomas/assert/v2"
|
|
)
|
|
|
|
func TestDelete(t *testing.T) {
|
|
type TestCase struct {
|
|
In *DeleteStatement
|
|
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: "delete 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")
|
|
})
|
|
}
|
|
}
|