forked from slicebit/qb
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dialect_test.go
35 lines (30 loc) · 945 Bytes
/
dialect_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
package qb
import (
"errors"
"github.com/stretchr/testify/assert"
"testing"
)
func TestDefaultDialect(t *testing.T) {
dialect := NewDialect("default")
assert.Implements(t, (*Compiler)(nil), dialect.GetCompiler())
assert.Equal(t, false, dialect.SupportsUnsigned())
assert.Equal(t, "test", dialect.Escape("test"))
assert.Equal(t, false, dialect.Escaping())
dialect.SetEscaping(true)
assert.Equal(t, true, dialect.Escaping())
assert.Equal(t, "`test`", dialect.Escape("test"))
assert.Equal(t, []string{"`test`"}, dialect.EscapeAll([]string{"test"}))
assert.Equal(t, "", dialect.Driver())
autoincCol := Column("id", Int()).PrimaryKey().AutoIncrement()
assert.Equal(t,
"INT PRIMARY KEY AUTO INCREMENT",
dialect.AutoIncrement(&autoincCol))
err := errors.New("xxx")
qbErr := dialect.WrapError(err)
assert.Equal(t, err, qbErr.Orig)
}
func TestGetDialect(t *testing.T) {
assert.Panics(t, func() {
NewDialect("unknown")
})
}