func loadCalendar(hackPath, talkPath string) { c := make(chan parse.CalEvent) go parse.ParseEvent(hackPath, c) go parse.ParseEvent(talkPath, c) CalEvents.hacknight, CalEvents.talknight = <-c, <-c }
//LoadCalendar reads in the Events from their JSON definitions and //applies it to global 'events' variable for access func LoadCalendar() { c := make(chan parse.CalEvent) go parse.ParseEvent("hacknights.json", c) go parse.ParseEvent("talknights.json", c) CalEvents.hacknight, CalEvents.talknight = <-c, <-c }
func TestTalkTargetEventParsing(t *testing.T) { c := make(chan parse.CalEvent) go parse.ParseEvent("testing/resources/talking.json", c) jsn := <-c //fmt.Printf("%#v\n", jsn) if jsn.Location != "ESRI" { t.Errorf("Location incorrect: %#v", jsn) } if jsn.Lat != 45.521525 { t.Errorf("Latitude incorrect(45.521525): %#v", jsn) } if jsn.Localtime != "Tuesday" { t.Errorf("Localtime incorrect(Tuesday): %#v", jsn) } }
func TestEventResponse(t *testing.T) { c := make(chan parse.CalEvent) go parse.ParseEvent("testing/resources/talking.json", c) jsn := <-c out := EventResponse(jsn, "ropes", "Talk Night") fmt.Printf("%#v\n", out) if len(out) != 3 { t.Errorf("Three strings not returned!") } for i, v := range out { if v == "" { t.Errorf("String %d empty!: '%s'", i, v) } } }