Example #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())
}
Example #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
}
Example #3
0
func getOrganizationId() interface{} {
	organization := u.SelectTestOrganization()
	return organization.Id
}