-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresponse_test.go
64 lines (50 loc) · 1.12 KB
/
response_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package goatquery
import (
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
)
func Test_AllPropertiesAreReturned(t *testing.T) {
query := Query{}
data := []User{
{
Base: Base{Id: uuid.New()},
Firstname: "John",
Lastname: "Doe",
Email: "John.Doe@email.com",
},
}
res := BuildPagedResponse(data, query, nil)
assert.Contains(t, res.Value[0], "id")
}
func Test_SelectUUIDTypeReturnsCorrectValue(t *testing.T) {
field := "id"
query := Query{Select: field}
uuid := uuid.New()
data := []User{
{
Base: Base{Id: uuid},
Firstname: "John",
Lastname: "Doe",
Email: "John.Doe@email.com",
},
}
res := BuildPagedResponse(data, query, nil)
assert.Equal(t, uuid, res.Value[0][field])
}
func Test_SelectIntTypeReturnsCorrectValue(t *testing.T) {
field := "age"
query := Query{Select: field}
age := uint(21)
data := []User{
{
Age: age,
Base: Base{Id: uuid.New()},
Firstname: "John",
Lastname: "Doe",
Email: "John.Doe@email.com",
},
}
res := BuildPagedResponse(data, query, nil)
assert.Equal(t, age, res.Value[0][field])
}