-
Notifications
You must be signed in to change notification settings - Fork 0
/
transform_test.go
49 lines (44 loc) · 996 Bytes
/
transform_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package sqlGoString
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTransform(t *testing.T) {
testCases := []struct {
queryName string
expected string
isError bool
}{
{
queryName: "query_test",
expected: "SELECT * FROM test_table",
isError: false,
},
{
queryName: "query_test2",
expected: "SELECT * FROM test_table2\nWHERE id = $1",
isError: false,
},
{
queryName: "query_test3",
expected: "SELECT * FROM test_table3 t\nWHERE id = $1\nAND t.name = $2",
isError: false,
},
{
queryName: "non_existing_query",
expected: "",
isError: true,
},
}
for _, tc := range testCases {
t.Run(tc.queryName, func(t *testing.T) {
sqlQuery, err := Transform(tc.queryName)
if tc.isError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, tc.expected, sqlQuery)
}
})
}
}