forked from hswaw/hscloud
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package calendar
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
)
|
|
|
|
func TestUpcomingEvents(t *testing.T) {
|
|
r, err := os.Open("test.ical")
|
|
if err != nil {
|
|
t.Fatalf("Could not open test ical: %v", err)
|
|
}
|
|
ti := time.Unix(1626011785, 0)
|
|
|
|
events, err := parseUpcomingEvents(ti, r)
|
|
if err != nil {
|
|
t.Fatalf("getUpcomingEvents: %v", err)
|
|
}
|
|
|
|
want := []*UpcomingEvent{
|
|
{
|
|
UID: "65cd51ba-2fd7-475e-a274-61d19c186b66",
|
|
Summary: "test event please ignore",
|
|
Description: "I am a description",
|
|
Start: &EventTime{
|
|
Time: time.Unix(1626091200, 0),
|
|
},
|
|
End: &EventTime{
|
|
Time: time.Unix(1626093000, 0),
|
|
},
|
|
},
|
|
{
|
|
UID: "2f874784-1e09-4cdc-8ae6-185c9ee36be0",
|
|
Summary: "many days",
|
|
Description: "I am a multiline\n\ndescription\n\nwith a link: https://example.com/foo\n\nbarfoo",
|
|
Start: &EventTime{
|
|
Time: time.Unix(1626134400, 0),
|
|
WholeDay: true,
|
|
},
|
|
End: &EventTime{
|
|
Time: time.Unix(1626393600, 0),
|
|
WholeDay: true,
|
|
},
|
|
},
|
|
}
|
|
|
|
if diff := cmp.Diff(events, want); diff != "" {
|
|
t.Errorf("%s", diff)
|
|
}
|
|
}
|