示例#1
0
文件: team.go 项目: pjherring/ggc
//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
}
示例#2
0
func TestCreateTeam(t *T) {
	beforeTeamTest()

	team, err := table.CreateTeam(1, "The Team")
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, team.TeamId > 0, "no id set")
	rdtest.Assert(t, team.Name == "The Team", "wrong team name")
	rdtest.Assert(t, team.TrackId == 1, "wrong track id")
}