forked from smlxl/sqlparser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtruncate_query_test.go
More file actions
47 lines (44 loc) · 871 Bytes
/
Copy pathtruncate_query_test.go
File metadata and controls
47 lines (44 loc) · 871 Bytes
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
package sqlparser
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTruncateQuery(t *testing.T) {
tests := []struct {
query string
max int
want string
}{
{
query: "select 111",
max: 2,
want: "select 111",
},
{
query: "select 1111",
max: 2,
want: " [TRUNCATED]",
},
{
query: "select 11111",
max: 2,
want: " [TRUNCATED]",
},
{
query: "select * from test where name = 'abc'",
max: 30,
want: "select * from test [TRUNCATED]",
},
{
query: "select * from test where name = 'abc'",
max: 1005,
want: "select * from test where name = 'abc'",
},
}
for _, tt := range tests {
t.Run(fmt.Sprintf("%s-%d", tt.query, tt.max), func(t *testing.T) {
assert.Equalf(t, tt.want, TruncateQuery(tt.query, tt.max), "TruncateQuery(%v, %v)", tt.query, tt.max)
})
}
}