forked from andlabs/ews
-
Notifications
You must be signed in to change notification settings - Fork 29
/
create_item_test.go
68 lines (61 loc) · 1.93 KB
/
create_item_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
package ews
import (
"encoding/xml"
"github.com/stretchr/testify/assert"
"log"
"testing"
"time"
)
func Test_marshal_CalendarItem(t *testing.T) {
attendee := make([]Attendee, 0)
attendee = append(attendee,
Attendee{Mailbox: Mailbox{EmailAddress: "User1@example.com"}},
Attendee{Mailbox: Mailbox{EmailAddress: "User2@example.com"}},
)
attendees := make([]Attendees, 0)
attendees = append(attendees, Attendees{Attendee: attendee})
start, _ := time.Parse(time.RFC3339, "2006-11-02T14:00:00Z")
end, _ := time.Parse(time.RFC3339, "2006-11-02T15:00:00Z")
citem := &CalendarItem{
Subject: "Planning Meeting",
Body: Body{
BodyType: "Text",
Body: []byte("Plan the agenda for next week's meeting."),
},
ReminderIsSet: true,
ReminderMinutesBeforeStart: 60,
Start: start,
End: end,
IsAllDayEvent: false,
LegacyFreeBusyStatus: "Busy",
Location: "Conference Room 721",
RequiredAttendees: attendees,
}
xmlBytes, err := xml.MarshalIndent(citem, "", " ")
if err != nil {
log.Fatal(err)
}
assert.Equal(t, `<CalendarItem>
<t:Subject>Planning Meeting</t:Subject>
<t:Body BodyType="Text">Plan the agenda for next week's meeting.</t:Body>
<t:ReminderIsSet>true</t:ReminderIsSet>
<t:ReminderMinutesBeforeStart>60</t:ReminderMinutesBeforeStart>
<t:Start>2006-11-02T14:00:00Z</t:Start>
<t:End>2006-11-02T15:00:00Z</t:End>
<t:IsAllDayEvent>false</t:IsAllDayEvent>
<t:LegacyFreeBusyStatus>Busy</t:LegacyFreeBusyStatus>
<t:Location>Conference Room 721</t:Location>
<t:RequiredAttendees>
<t:Attendee>
<t:Mailbox>
<t:EmailAddress>User1@example.com</t:EmailAddress>
</t:Mailbox>
</t:Attendee>
<t:Attendee>
<t:Mailbox>
<t:EmailAddress>User2@example.com</t:EmailAddress>
</t:Mailbox>
</t:Attendee>
</t:RequiredAttendees>
</CalendarItem>`, string(xmlBytes))
}