Example #1
0
func TestMarkPhraseInUse(t *T) {
	beforePhraseTest()
	err := table.MarkPhraseInUse(1, 1)
	rdtest.Assert(t, err == nil, err)
	p_id, p, err := table.UnusedPhrase()
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, p == "phrase_2", "%s", p)
	err = table.MarkPhraseInUse(2, p_id)
	rdtest.Assert(t, err == nil, err)
	p_id, p, err = table.UnusedPhrase()
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, p == "phrase_3", "%s", p)
}
Example #2
0
//CreateTeam will store a team and put a team on a track
func CreateTeam(teamName, telephoneNumber string) (u *record.User, t *record.Team, err error) {
	//get an unused phrase
	phrase_id, phrase, err := table.UnusedPhrase()
	if err != nil {
		return
	}

	//get a track
	track_id, err := table.LeastUsedTrackId(time.Now())
	if err != nil {
		return
	}

	//create a team record
	t, err = table.CreateTeam(track_id, teamName)
	if err != nil {
		return
	}

	if err = table.MarkPhraseInUse(t.TeamId, phrase_id); err != nil {
		return
	}

	t.Phrase = phrase

	//store a user
	u, err = table.CreateUser(telephoneNumber, t.TeamId)

	return
}