-
Notifications
You must be signed in to change notification settings - Fork 0
/
drift_views_test.go
40 lines (37 loc) · 1017 Bytes
/
drift_views_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
package pgutil
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestStripIdent(t *testing.T) {
for _, testCase := range []struct {
name string
input string
expected string
}{
{
name: "single line",
input: "CREATE VIEW IF NOT EXISTS v AS SELECT 1;",
expected: "CREATE VIEW IF NOT EXISTS v AS SELECT 1;",
},
{
name: "single line with ident",
input: " CREATE VIEW IF NOT EXISTS v AS SELECT 1;",
expected: "CREATE VIEW IF NOT EXISTS v AS SELECT 1;",
},
{
name: "multi line, common indent",
input: " CREATE VIEW IF NOT EXISTS v AS\n SELECT 1;",
expected: "CREATE VIEW IF NOT EXISTS v AS\nSELECT 1;",
},
{
name: "multi line, jagged indent",
input: " CREATE VIEW IF NOT EXISTS v AS\n SELECT *\n FROM t;",
expected: "CREATE VIEW IF NOT EXISTS v AS\n SELECT *\n FROM t;",
},
} {
t.Run(testCase.name, func(t *testing.T) {
assert.Equal(t, testCase.expected, stripIdent(testCase.input))
})
}
}