Exemplo n.º 1
0
func TestCreateTeamProgress_PreventDuplicate(t *T) {
	beforeTeamProgressTest()

	p, err := table.CreateTeamProgress(1, 1)
	rdtest.Assert(t, p == nil)
	rdtest.Assert(t, err == table.TeamProgressExists)
}
Exemplo n.º 2
0
func Begin(teamId int64) error {
	track, err := table.FindTrackForTeam(teamId)
	if err != nil {
		return err
	}

	_, err = table.CreateTeamProgress(teamId, track.QuestionIdOrder[0])
	return err
}
Exemplo n.º 3
0
func TestCreateTeamProgress(t *T) {
	beforeTeamProgressTest()

	p, err := table.CreateTeamProgress(2, 1)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, p.TeamId == 2)
	rdtest.Assert(t, p.ClueId == 1)

	currentClue, err := table.FindClueWithProgressForTeam(2)
	rdtest.Assert(t, err == nil)
	rdtest.Assert(t, currentClue.Clue.ClueId == 1)
	rdtest.Assert(t, currentClue.TeamId == 2)
}
Exemplo n.º 4
0
//Start progress on a track for a team
func startTrackForTeam(team *record.Team) (*models.Clue, error) {

	track, err := table.FindTrack(team.TrackId)
	if err != nil {
		return nil, err
	}

	//find the clue
	clue, err := table.FindClue(track.QuestionIdOrder[0])
	if err != nil {
		return nil, err
	}

	_, err = table.CreateTeamProgress(team.TeamId, clue.ClueId)
	if err != nil {
		return nil, err
	}

	return models.ClueFromCurrentClue(clue), nil
}