Files
sqimple/delete_test.go
T

48 lines
1018 B
Go
Raw Normal View History

2026-07-07 20:29:58 +01:00
package sqimple
2026-07-07 20:07:15 +01:00
import (
"testing"
"github.com/alecthomas/assert/v2"
)
func TestDelete(t *testing.T) {
type TestCase struct {
2026-07-07 21:20:58 +01:00
In *DeleteStatement
2026-07-07 20:07:15 +01:00
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"),
2026-07-07 21:20:58 +01:00
String: "delete from customer as c",
2026-07-07 20:07:15 +01:00
},
{
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")
})
}
}