forked from nleof/goyesql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
goyesql_test.go
47 lines (41 loc) · 1.05 KB
/
goyesql_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
package goyesql
import (
"testing"
)
func TestMustParseFilePanic(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("MustParseFile should panic if an error occurs, got '%s'", r)
}
}()
MustParseFile("tests/samples/missing.sql")
}
func TestMustParseFileNoPanic(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Errorf("MustParseFile should not panic if no error occurs, got '%s'", r)
}
}()
MustParseFile("tests/samples/valid.sql")
}
func TestMustParseBytesPanic(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("MustParseBytes should panic if an error occurs, got '%s'", r)
}
}()
MustParseBytes([]byte("I won't work"))
}
func TestMustParseBytesNoPanic(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Errorf("MustParseBytes should not panic if an error occurs, got '%s'", r)
}
}()
MustParseBytes([]byte("-- name: byte-me\nSELECT * FROM bytes;"))
}
func BenchmarkMustParseFile(b *testing.B) {
for i := 0; i < b.N; i++ {
MustParseFile("tests/samples/valid.sql")
}
}