-
Notifications
You must be signed in to change notification settings - Fork 0
/
human_test.go
44 lines (38 loc) · 856 Bytes
/
human_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
package test
import (
"testing"
"goTest/human"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/types"
)
func TestHumanStruct(t *testing.T) {
tests := []struct {
name string
targetAge []int
humanTarget human.Person
want bool
}{
{
name: "Compare Age Correct",
targetAge: []int{10, 20},
humanTarget: human.Person{Age: []int{30, 50}},
want: true,
},
{
name: "Compare Age Incorrect",
targetAge: []int{11, 25},
humanTarget: human.Person{Age: []int{32, 60}},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
g.Expect(tt.humanTarget).Should(MatchAge(tt.targetAge))
})
}
}
// MatchAge is the Custom Gomega Testing Function
func MatchAge(a []int) types.GomegaMatcher {
return &human.Person{Age: a}
}