Esempio n. 1
0
func TestNextClue(t *T) {
	track := record.Track{
		QuestionIdOrder: []int64{1, 2, 3},
	}

	next, err := track.NextClue(1)
	rdtest.Assert(t, err == nil)
	rdtest.Assert(t, next == 2)

	next, err = track.NextClue(2)
	rdtest.Assert(t, err == nil)
	rdtest.Assert(t, next == 3)

	next, err = track.NextClue(3)
	rdtest.Assert(t, err == record.NoCluesRemain)

	next, err = track.NextClue(4)
	rdtest.Assert(t, err == record.WrongTrack)
}
Esempio n. 2
0
func FindTrack(trackId int64) (*record.Track, error) {
	t := new(record.Track)
	err := FindOne(t, "SELECT "+t.GetSelectAll()+" WHERE track_id = ?", trackId)
	return t, err
}