-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhyperbun_test.go
More file actions
44 lines (36 loc) · 1.21 KB
/
hyperbun_test.go
File metadata and controls
44 lines (36 loc) · 1.21 KB
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
package hyperbun
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/uptrace/bun"
)
type testStruct struct {
bun.BaseModel `bun:"table:test_struct,alias:rt"`
ID int `bun:"id,pk,autoincrement"`
}
func TestHyperbunTableForType(t *testing.T) {
assert.Equal(t, "test_struct", hyperbunTableForType[testStruct]())
assert.Equal(t, "test_struct", hyperbunTableForType[*testStruct]())
assert.Equal(t, "test_struct", hyperbunTableForType[[]testStruct]())
assert.Equal(t, "test_struct", hyperbunTableForType[[]*testStruct]())
assert.Equal(t, "test_struct", hyperbunTableForType[*[]testStruct]())
}
func TestAnnotateEven(t *testing.T) {
assert.Equal(t,
"performing TestAnnotate hello='world' id='0': test_error",
annotate(errors.New("test_error"), "TestAnnotate", "hello", "world", "id", 0).Error(),
)
}
func TestAnnotateOdd(t *testing.T) {
assert.Equal(t,
"performing TestAnnotate hello='world' id='0' odd='<missing value>': test_error",
annotate(errors.New("test_error"), "TestAnnotate", "hello", "world", "id", 0, "odd").Error(),
)
}
func TestAnnotateNoKV(t *testing.T) {
assert.Equal(t,
"performing TestAnnotate: test_error",
annotate(errors.New("test_error"), "TestAnnotate").Error(),
)
}