forked from open-networks/go-msgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAttendee_test.go
108 lines (103 loc) · 2.62 KB
/
Attendee_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package msgraph
import (
"testing"
"time"
)
var (
// First Attendee used for the Unit tests
testAttendee1 = Attendee{Name: "Testname", Email: "[email protected]", Type: "attendee", ResponseStatus: ResponseStatus{Response: "accepted", Time: time.Now()}}
// Second Attendee used for the Unit tests
testAttendee2 = Attendee{Name: "Testuser", Email: "[email protected]", Type: "attendee", ResponseStatus: ResponseStatus{Response: "declined", Time: time.Now()}}
)
func TestAttendee_Equal(t *testing.T) {
type args struct {
other Attendee
}
tests := []struct {
name string
a Attendee
args args
want bool
}{
{
name: "All equal",
a: testAttendee1,
args: args{other: testAttendee1},
want: true,
}, {
name: "non-equal",
a: testAttendee1,
args: args{other: testAttendee2},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.a.Equal(tt.args.other); got != tt.want {
t.Errorf("Attendee.Equal() = %v, want %v", got, tt.want)
}
})
}
}
func TestAttendee_UnmarshalJSON(t *testing.T) {
type args struct {
data []byte
}
tests := []struct {
name string
a *Attendee
args args
wantErr bool
}{
{
name: "All good",
a: &Attendee{},
args: args{data: []byte(
`{ "Type" : "organizer",
"Status": {"response" : "accepted", "time" : "` + time.Now().Format(time.RFC3339Nano) + `"},
"emailAddress" : {
"name" : "TestUserName",
"address": "[email protected]"
}}`)},
wantErr: false,
}, {
name: "wrong json",
a: &Attendee{},
args: args{data: []byte(
`{ "Type" : "organizer",
"Status": {"response" : "accepted", "time" : "` + time.Now().Format(time.RFC3339Nano) + `"},
"emailAddress" : {
"name" : "TestUserName",
"address": "[email protected]",
}}`)},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.a.UnmarshalJSON(tt.args.data); (err != nil) != tt.wantErr {
t.Errorf("Attendee.UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestAttendee_String(t *testing.T) {
tests := []struct {
name string
a Attendee
want string
}{
{
name: "Test String-func",
a: testAttendee1,
want: "Name: Testname, Type: attendee, E-mail: [email protected], ResponseStatus: Response: accepted, Time: " + testAttendee1.ResponseStatus.Time.Format(time.RFC3339Nano),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.a.String(); got != tt.want {
t.Errorf("Attendee.String() = %v, want %v", got, tt.want)
}
})
}
}