Exemplo n.º 1
0
func (t *GameTest) TestIsRunning() {
	u.InsertTestOrganization()
	org := u.SelectTestOrganization()
	now := time.Now()
	twoDaysAgo := now.Add(u.TwoDaysBack)
	twoDaysHence := now.Add(u.TwoDaysForward)
	oneDayAgo := now.Add(u.OneDayBack)
	oneDayHence := now.Add(u.OneDayForward)
	current := &models.Game{0,
		"name",
		"slug",
		org.Id,
		"US/Pacific",
		&twoDaysAgo,
		&oneDayHence,
		&oneDayAgo,
		&twoDaysHence,
		"A test game",
		models.TimeTrackedModel{},
	}
	err := controllers.Dbm.Insert(current)
	t.Assert(err == nil)
	t.Assert(current.IsRunning())

	past := &models.Game{0,
		"name",
		"slug",
		org.Id,
		"US/Pacific",
		&twoDaysAgo,
		&oneDayHence,
		&twoDaysAgo,
		&oneDayAgo,
		"A test game",
		models.TimeTrackedModel{},
	}
	err = controllers.Dbm.Insert(past)
	t.Assert(err == nil)
	t.Assert(!past.IsRunning())

	future := &models.Game{0,
		"name",
		"slug",
		org.Id,
		"US/Pacific",
		&twoDaysAgo,
		&oneDayHence,
		&oneDayHence,
		&twoDaysHence,
		"A test game",
		models.TimeTrackedModel{},
	}
	err = controllers.Dbm.Insert(future)
	t.Assert(err == nil)
	t.Assert(!future.IsRunning())
}
Exemplo n.º 2
0
// generate some number of organization objects in JSON
func generateMemberJson() string {
	u.InsertTestUser()
	u.InsertTestOrganization()
	u.InsertTestGame()
	jsn := u.GenerateJson(
		"members",
		map[string]func() interface{}{
			"user_id":         func() interface{} { return u.SelectTestUser().Id },
			"organization_id": func() interface{} { return u.SelectTestOrganization().Id },
		},
		1,
	)

	return jsn
}
Exemplo n.º 3
0
// generate some number of user objects in JSON
func generateGameJson() string {
	u.InsertTestOrganization()
	now := time.Now().UTC()
	later := now.Add(12 * time.Hour)
	tomorrow := now.Add(24 * time.Hour)
	tomorrowLater := later.Add(24 * time.Hour)
	jsn := u.GenerateJson(
		"games",
		map[string]func() interface{}{
			"name":                    u.GenerateWord,
			"slug":                    u.GenerateSlug,
			"organization_id":         getOrganizationId,
			"timezone":                func() interface{} { return "US/Pacific" },
			"registration_start_time": func() interface{} { return now.Format(time.RFC3339) },
			"registration_end_time":   func() interface{} { return tomorrow.Format(time.RFC3339) },
			"running_start_time":      func() interface{} { return later.Format(time.RFC3339) },
			"running_end_time":        func() interface{} { return tomorrowLater.Format(time.RFC3339) },
		},
		1,
	)

	return jsn
}