add insert statement
This commit is contained in:
@@ -6,6 +6,40 @@ import (
|
||||
"github.com/alecthomas/assert/v2"
|
||||
)
|
||||
|
||||
func TestInsertTable(t *testing.T) {
|
||||
type TestCase struct {
|
||||
In string
|
||||
IsValid bool
|
||||
Table string
|
||||
As string
|
||||
}
|
||||
|
||||
testCases := []TestCase{
|
||||
{
|
||||
In: "into customer",
|
||||
IsValid: true,
|
||||
Table: "customer",
|
||||
},
|
||||
{
|
||||
In: "into customer as c",
|
||||
IsValid: true,
|
||||
Table: "customer",
|
||||
As: "c",
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.In, func(t *testing.T) {
|
||||
it := InsertTable(testCase.In)
|
||||
table, as, ok := it.Parse()
|
||||
|
||||
assert.Equal(t, testCase.IsValid, ok, "incorrect test case")
|
||||
assert.Equal(t, testCase.Table, table, "parsed table incorrectly")
|
||||
assert.Equal(t, testCase.As, as, "parsed as incorrectly")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectTable(t *testing.T) {
|
||||
type TestCase struct {
|
||||
In string
|
||||
|
||||
Reference in New Issue
Block a user