func TestCreateTeamProgress_PreventDuplicate(t *T) { beforeTeamProgressTest() p, err := table.CreateTeamProgress(1, 1) rdtest.Assert(t, p == nil) rdtest.Assert(t, err == table.TeamProgressExists) }
func Begin(teamId int64) error { track, err := table.FindTrackForTeam(teamId) if err != nil { return err } _, err = table.CreateTeamProgress(teamId, track.QuestionIdOrder[0]) return err }
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) }
//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 }