示例#1
0
func TestCalendarNow(t *testing.T) {
	c, err := calendar.New("", "", "")
	if err != nil {
		t.Fatal(err)
	}
	c.FreeBusy()
	t.Log(c.HTML())
}
示例#2
0
func TestCalendarHistoric(t *testing.T) {
	c, err := calendar.New("2015-12-01", "", "")
	if err != nil {
		t.Fatal(err)
	}
	c.FreeBusy()
	t.Log(c.HTML())
}
示例#3
0
文件: calendar.go 项目: miekg/nlgids
// WebCalendar returns a calendar in table form. All-day events from the
// subject are greyed out,  as are pasted days.
func (n *NLgids) WebCalendar(w http.ResponseWriter, r *http.Request) (int, error) {
	date := r.PostFormValue("date") // YYYY-MM-DD, empty is allowed.
	c, err := calendar.New(date, n.Config.Subject, n.Config.Secret)
	if err != nil {
		return http.StatusBadRequest, nil
	}
	c.FreeBusy()
	fmt.Fprintf(w, c.HTML())

	return http.StatusOK, nil
}
示例#4
0
func TestFreeBusy(t *testing.T) {
	date := "2016-08-02" // planned holiday date
	subject := "*****@*****.**"
	secret := "/etc/caddy/NLgids-fcbeb7928cdb.json"

	if _, err := os.Open(secret); err != nil {
		t.Logf("can open secret file, not performing test: %s", err)
		return
	}

	c, err := calendar.New(date, subject, secret)
	if err != nil {
		t.Errorf("can get new calendar: %s", err)
	}
	c.FreeBusy()

	tm := time.Date(2016, time.August, 2, 0, 0, 0, 0, time.UTC)
	days := c.Days()
	if days[tm].Available != calendar.Busy {
		t.Errorf("day %s should be busy, it is not", days[tm].Available)
	}
}