示例#1
0
func TestTimeTableSave(t *testing.T) {
	proInp := map[string]interface{}{
		"timeTable": []interface{}{
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00",
			"0:00-0:00",
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00, 13:00-17:00",
			"8:00-12:00",
			"0:00-0:00",
		},
	}
	err := tt.Save(newTT(), proInp)
	if err != nil {
		t.Fatal(err)
	}
	res, err := newTT().Find()
	if err != nil {
		t.Fatal(err)
	}
	if len(res) != 1 {
		t.Fatal(err)
	}
	_, err = evenday.GenericToTimeTable(res[0]["timeTable"].([]interface{}))
	if err != nil {
		t.Fatal(err)
	}
}
示例#2
0
文件: meeting.go 项目: crufter/nocrud
func (e *Entries) getTimeTable(prof iface.Id) (evenday.TimeTable, error) {
	ttFilter, err := e.db.NewFilter(e.timeTableColl, nil)
	empty := evenday.TimeTable{}
	if err != nil {
		return empty, err
	}
	timeTableQ := map[string]interface{}{
		"createdBy": prof,
	}
	ttFilter.AddQuery(timeTableQ)
	ttC, err := ttFilter.Count()
	if err != nil {
		return empty, err
	}
	if ttC != 1 {
		return empty, fmt.Errorf("Number of timeTables is not one.")
	}
	timeTables, err := ttFilter.Find()
	if err != nil {
		return empty, err
	}
	timeTable, err := evenday.GenericToTimeTable(timeTables[0]["timeTable"].([]interface{}))
	if err != nil {
		return empty, err
	}
	return timeTable, nil
}