Esempio n. 1
0
func TestCreateDuplicateUser(t *T) {
	beforeUserTest()
	_, err := table.CreateUser("123 123 1234", 1)
	rdtest.Assert(t, err == nil, err)
	_, err = table.CreateUser("123 123 1234", 1)
	rdtest.Assert(t, err == table.DuplicateUser, "%s", err)
}
Esempio n. 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
}
Esempio n. 3
0
func TestCreateUser(t *T) {
	beforeUserTest()
	u, err := table.CreateUser("123 123 1234", 1)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, u.UserId > 0, "no user id")
	rdtest.Assert(t, u.Telephone == "1231231234", "wrong telephone")
	rdtest.Assert(t, u.TeamId == 1, "wrong team id")
	rdtest.Assert(t, !u.DidAcceptWaiver, "should not have accepted waiver")
}
Esempio n. 4
0
func JoinTeam(
	phrase,
	telephoneNumber string) (u *record.User, t *record.Team, err error) {

	t, err = table.FindTeamByPhrase(phrase)
	if err != nil {
		return
	}

	u, err = table.CreateUser(telephoneNumber, t.TeamId)
	if err == table.DuplicateUser {
		u, err = table.FindUserByTelephoneTeam(telephoneNumber, t.TeamId)
	}
	return
}