-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathdocument_meta_test.go
45 lines (35 loc) · 1.06 KB
/
document_meta_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
package rel
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDocumentMeta_Association(t *testing.T) {
var (
docMeta = getDocumentMeta(reflect.TypeOf(User{}), false)
assocMeta = docMeta.Association("address")
)
assert.Equal(t, getDocumentMeta(reflect.TypeOf(Address{}), false), assocMeta.DocumentMeta())
}
func TestDocumentMeta_Association_ptr(t *testing.T) {
var (
docMeta = getDocumentMeta(reflect.TypeOf(User{}), false)
assocMeta = docMeta.Association("work_address")
)
assert.Equal(t, getDocumentMeta(reflect.TypeOf(Address{}), false), assocMeta.DocumentMeta())
}
func TestDocumentMeta_Association_slice(t *testing.T) {
var (
docMeta = getDocumentMeta(reflect.TypeOf(User{}), false)
assocMeta = docMeta.Association("emails")
)
assert.Equal(t, getDocumentMeta(reflect.TypeOf(Email{}), false), assocMeta.DocumentMeta())
}
func TestDocumentMeta_Association_notFound(t *testing.T) {
var (
docMeta = getDocumentMeta(reflect.TypeOf(User{}), false)
)
assert.Panics(t, func() {
docMeta.Association("invalid")
})
}