-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_test.go
39 lines (30 loc) · 813 Bytes
/
init_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
package dat
import (
"bytes"
"fmt"
"testing"
"gopkg.in/mgutz/dat.v1/postgres"
"gopkg.in/stretchr/testify.v1/assert"
)
func init() {
Dialect = postgres.New()
}
func quoteSQL(sqlFmt string, cols ...string) string {
args := make([]interface{}, len(cols))
for i := range cols {
args[i] = quoteColumn(cols[i])
}
return fmt.Sprintf(sqlFmt, args...)
}
func quoteColumn(column string) string {
var buffer bytes.Buffer
Dialect.WriteIdentifier(&buffer, column)
return buffer.String()
}
func checkSliceEqual(t *testing.T, expected, actual []interface{}, msgAndArgs ...interface{}) bool {
if fmt.Sprintf("%v", expected) != fmt.Sprintf("%v", actual) {
return assert.Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n"+
" != %#v (actual)", expected, actual), msgAndArgs...)
}
return true
}