Exemple #1
0
func beforeClueTest() {

	table.LoadFixtures(table.Fixtures{
		"questions": []table.RowFixture{
			table.RowFixture{
				"question_id": 1,
				"text":        "Text 1",
				"answer":      "Answer 1",
				"hint_one":    "Hint 1A",
				"hint_two":    "Hint 1B",
				"description": "Description 1",
				"is_enabled":  1,
			},
			table.RowFixture{
				"question_id": 2,
				"text":        "Text 2",
				"answer":      "Answer 2",
				"hint_one":    "Hint 2A",
				"hint_two":    "Hint 2B",
				"description": "Description 2",
				"is_enabled":  1,
			},
		},
		"team_progress": []table.RowFixture{
			table.RowFixture{
				"team_id":     1,
				"question_id": 1,
				"hint_cnt":    0,
			},
		},
	})

}
Exemple #2
0
func TestLeastUsedTrackId_NoTeamTracks(t *T) {
	table.LoadFixtures(table.Fixtures{
		"team_tracks": []table.RowFixture{},
		"tracks": []table.RowFixture{
			table.RowFixture{
				"track_id":          1,
				"question_id_order": "1|2|3",
				"start_time":        time.Now().Add(-1 * time.Hour),
				"end_time":          time.Now().Add(1 * time.Hour),
			},
			table.RowFixture{
				"track_id":          2,
				"question_id_order": "3|2|1",
				"start_time":        time.Now().Add(-1 * time.Hour),
				"end_time":          time.Now().Add(1 * time.Hour),
			},
			table.RowFixture{
				"track_id":          3,
				"question_id_order": "2|1|3",
				"start_time":        time.Now().Add(-1 * time.Hour),
				"end_time":          time.Now().Add(1 * time.Hour),
			},
		},
	})

	trackId, err := table.LeastUsedTrackId(time.Now())
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, trackId >= 1 && trackId <= 3, "%d", trackId)
}
Exemple #3
0
func beforeTeamTest() {

	table.LoadFixtures(table.Fixtures{
		"users": []table.RowFixture{
			table.RowFixture{
				"team_id":   100,
				"telephone": "1231231234",
			},
			table.RowFixture{
				"team_id":   100,
				"telephone": "3213213214",
			},
		},
		"teams": []table.RowFixture{
			table.RowFixture{
				"team_id":  100,
				"name":     "Team 100",
				"track_id": 50,
			},
		},
		"phrases": []table.RowFixture{
			table.RowFixture{
				"phrase_id": 1000,
				"phrase":    "phrase 1000",
				"team_id":   100,
			},
		},
	})
}
Exemple #4
0
func beforeTrackTest() {
	table.LoadFixtures(table.Fixtures{
		"teams": []table.RowFixture{
			table.RowFixture{"team_id": 1, "track_id": 1, "name": "Team 1"},
			table.RowFixture{"team_id": 2, "track_id": 1, "name": "Team 1"},
			table.RowFixture{"team_id": 3, "track_id": 1, "name": "Team 1"},
			table.RowFixture{"team_id": 4, "track_id": 2, "name": "Team 1"},
			table.RowFixture{"team_id": 5, "track_id": 2, "name": "Team 1"},
			table.RowFixture{"team_id": 6, "track_id": 3, "name": "Team 1"},
		},
		"users": []table.RowFixture{
			table.RowFixture{
				"team_id":   1,
				"telephone": "1231231234",
			},
			table.RowFixture{
				"team_id":   2,
				"telephone": "3213213214",
			},
		},
		"tracks": []table.RowFixture{
			table.RowFixture{
				"track_id":          1,
				"question_id_order": "1|2|3",
				"start_time":        time.Now().Add(-1 * time.Hour),
				"end_time":          time.Now().Add(1 * time.Hour),
				"name":              "Track 1",
			},
			table.RowFixture{
				"track_id":          2,
				"question_id_order": "3|2|1",
				"start_time":        time.Now().Add(-1 * time.Hour),
				"end_time":          time.Now().Add(1 * time.Hour),
				"name":              "Track 2",
			},
			table.RowFixture{
				"track_id":          3,
				"question_id_order": "2|1|3",
				"start_time":        time.Now().Add(-1 * time.Hour),
				"end_time":          time.Now().Add(1 * time.Hour),
				"name":              "Track 3",
			},
		},
	})
}
Exemple #5
0
func beforePhraseTest() {

	table.LoadFixtures(table.Fixtures{
		"phrases": []table.RowFixture{
			table.RowFixture{
				"phrase_id": 1,
				"phrase":    "phrase_1",
			},
			table.RowFixture{
				"phrase_id": 2,
				"phrase":    "phrase_2",
			},
			table.RowFixture{
				"phrase_id": 3,
				"phrase":    "phrase_3",
			},
		},
	})

}
Exemple #6
0
func beforeHintTest() {

	table.LoadFixtures(table.Fixtures{
		"hints": []table.RowFixture{
			table.RowFixture{
				"idx":         0,
				"question_id": 1,
				"hint":        "This is a hint",
			},
			table.RowFixture{
				"idx":         1,
				"question_id": 1,
				"hint":        "This is a loaction hint",
				"latitude":    12.12,
				"longitude":   12.12,
			},
		},
	})

}
Exemple #7
0
func beforeTeamTest() {
	table.LoadFixtures(table.Fixtures{
		"phrases": []table.RowFixture{
			table.RowFixture{"phrase_id": 1, "phrase": "phrase_1"},
			table.RowFixture{"phrase_id": 2, "phrase": "phrase_2"},
			table.RowFixture{"phrase_id": 3, "phrase": "phrase_3"},
		},
		"teams": []table.RowFixture{},
		"users": []table.RowFixture{},
		"challenges": []table.RowFixture{
			table.RowFixture{
				"challenge_id": 1, "name": "Challenge 1",
				"start_time": time.Now().Add(-2 * time.Hour),
				"end_time":   time.Now().Add(2 * time.Hour),
			},
		},
		"tracks": []table.RowFixture{
			table.RowFixture{"track_id": 1, "challenge_id": 1},
		},
	})

}
Exemple #8
0
func beforeUserTest() {
	table.LoadFixtures(table.Fixtures{
		"teams": []table.RowFixture{
			table.RowFixture{"team_id": 1, "track_id": 1, "name": "Team 1"},
			table.RowFixture{"team_id": 2, "track_id": 1, "name": "Team 1"},
			table.RowFixture{"team_id": 3, "track_id": 1, "name": "Team 1"},
			table.RowFixture{"team_id": 4, "track_id": 2, "name": "Team 1"},
			table.RowFixture{"team_id": 5, "track_id": 2, "name": "Team 1"},
			table.RowFixture{"team_id": 6, "track_id": 3, "name": "Team 1"},
		},
		"users": []table.RowFixture{
			table.RowFixture{
				"user_id": 100, "telephone": "9998887777",
				"team_id": 1, "did_accept_waiver": true,
			},
		},
		"phrases": []table.RowFixture{
			table.RowFixture{
				"phrase_id": 1000, "phrase": "the phrase", "team_id": 1,
			},
		},
	})
}
Exemple #9
0
func beforeHintTest() {
	table.LoadFixtures(table.Fixtures{
		"questions": []table.RowFixture{
			table.RowFixture{
				"question_id": 1,
				"text":        "Text 1",
				"answer":      "Answer 1",
				"hint_one":    "Hint 1A",
				"hint_two":    "Hint 1B",
				"description": "Description 1",
				"is_enabled":  1,
			},
		},
		"team_progress": []table.RowFixture{
			table.RowFixture{
				"team_id":     1,
				"question_id": 1,
				"hint_cnt":    0,
			},
		},
		"teams": []table.RowFixture{
			table.RowFixture{
				"team_id":  1,
				"name":     "Team 1",
				"track_id": 1,
			},
		},
		"tracks": []table.RowFixture{
			table.RowFixture{
				"track_id":          1,
				"question_id_order": "1|2|3|4",
				"start_time":        time.Now(),
			},
		},
	})
}
Exemple #10
0
func beforeCurrentTest() {
	table.LoadFixtures(table.Fixtures{
		"questions": []table.RowFixture{
			table.RowFixture{
				"question_id": 1,
				"text":        "Text 1",
				"answer":      "Answer 1",
				"hint_one":    "Hint 1A",
				"hint_two":    "Hint 1B",
				"description": "Description 1",
				"is_enabled":  1,
			},
			table.RowFixture{
				"question_id": 2,
				"text":        "Text 2",
				"answer":      "Answer 2",
				"hint_one":    "Hint 2A",
				"hint_two":    "Hint 2B",
				"description": "Description 2",
				"is_enabled":  0,
			},
			table.RowFixture{
				"question_id": 3,
				"text":        "Text 3",
				"answer":      "Answer 3",
				"hint_one":    "Hint 3A",
				"hint_two":    "Hint 3B",
				"description": "Description 3",
				"is_enabled":  1,
			},
			table.RowFixture{
				"question_id": 4,
				"text":        "Text 4",
				"answer":      "Answer 4",
				"hint_one":    "Hint 4A",
				"hint_two":    "Hint 4B",
				"description": "Description 4",
				"is_enabled":  1,
			},
		},
		"team_progress": []table.RowFixture{
			table.RowFixture{
				"team_id":     1,
				"question_id": 1,
				"hint_cnt":    0,
				"answer_time": time.Date(2016, 1, 1, 13, 0, 0, 0, time.UTC),
			},
			table.RowFixture{
				"team_id":     2,
				"question_id": 1,
				"hint_cnt":    2,
			},
			table.RowFixture{
				"team_id":     3,
				"question_id": 1,
				"hint_cnt":    0,
				"answer_time": time.Date(2016, 1, 1, 13, 0, 0, 0, time.UTC),
			},
			table.RowFixture{
				"team_id":     3,
				"question_id": 3,
				"hint_cnt":    0,
				"answer_time": time.Date(2016, 1, 1, 13, 0, 0, 0, time.UTC),
			},
			table.RowFixture{
				"team_id":     3,
				"question_id": 4,
				"hint_cnt":    1,
			},
			table.RowFixture{
				"team_id":     1,
				"question_id": 2,
				"hint_cnt":    0,
			},
		},
		"teams": []table.RowFixture{
			table.RowFixture{
				"team_id":  1,
				"name":     "Team 1",
				"track_id": 1,
			},
			table.RowFixture{
				"team_id":  2,
				"name":     "Team 2",
				"track_id": 2,
			},
			table.RowFixture{
				"team_id":  3,
				"name":     "Team 3",
				"track_id": 3,
			},
		},
		"tracks": []table.RowFixture{
			table.RowFixture{
				"track_id":          1,
				"question_id_order": "1|2|3|4",
				"start_time":        clueTestNow.Add(-24 * time.Hour),
				"end_time":          clueTestNow.Add(24 * time.Hour),
			},
		},
	})
}
Exemple #11
0
func beforeAnswerTest() {
	table.LoadFixtures(table.Fixtures{
		"questions": []table.RowFixture{
			table.RowFixture{
				"question_id": 1,
				"text":        "Text 1",
				"answer":      "Answer 1|1|1BA|1ba|trailing | prefixing",
				"hint_one":    "Hint 1A",
				"hint_two":    "Hint 1B",
				"description": "Description 1",
				"is_enabled":  1,
			},
			table.RowFixture{
				"question_id": 2,
				"text":        "Text 2",
				"answer":      "Answer 2",
				"hint_one":    "Hint 2A",
				"hint_two":    "Hint 2B",
				"description": "Description 2",
				"is_enabled":  0,
			},
			table.RowFixture{
				"question_id": 3,
				"text":        "Text 3",
				"answer":      "Answer 3|answer3|AnSWER33",
				"hint_one":    "Hint 3A",
				"hint_two":    "Hint 3B",
				"description": "Description 3",
				"is_enabled":  1,
			},
			table.RowFixture{
				"question_id": 4,
				"text":        "Text 4",
				"answer":      "Answer 4",
				"hint_one":    "Hint 4A",
				"hint_two":    "Hint 4B",
				"description": "Description 4",
				"is_enabled":  1,
			},
		},
		"team_progress": []table.RowFixture{
			table.RowFixture{
				"team_id":     1,
				"question_id": 1,
				"hint_cnt":    0,
			},
		},
		"teams": []table.RowFixture{
			table.RowFixture{
				"team_id":  1,
				"name":     "Team 1",
				"track_id": 1,
			},
		},
		"tracks": []table.RowFixture{
			table.RowFixture{
				"track_id":          1,
				"question_id_order": "1|2|3|4",
				"start_time":        time.Now().Add(time.Hour * -24),
				"end_time":          time.Now().Add(time.Hour * 24),
			},
		},
	})
}
Exemple #12
0
func beforeTeamProgressTest() {

	table.LoadFixtures(table.Fixtures{
		"teams": []table.RowFixture{
			table.RowFixture{
				"team_id":  20,
				"name":     "Team 20",
				"track_id": 1,
			},
			table.RowFixture{
				"team_id":  21,
				"name":     "Team 20",
				"track_id": 2,
			},
			table.RowFixture{
				"team_id":     22,
				"name":        "Team 22",
				"track_id":    1,
				"finish_time": time.Now(),
			},
		},
		"phrases": []table.RowFixture{
			table.RowFixture{
				"phrase_id": 1,
				"team_id":   20,
				"phrase":    "Phrase 1",
			},
			table.RowFixture{
				"phrase_id": 2,
				"team_id":   21,
				"phrase":    "Phrase 2",
			},
			table.RowFixture{
				"phrase_id": 3,
				"team_id":   22,
				"phrase":    "Phrase 3",
			},
		},
		"tracks": []table.RowFixture{
			table.RowFixture{
				"track_id":          1,
				"question_id_order": "1|2|3",
				"start_time":        time.Date(2016, 6, 1, 0, 0, 0, 0, time.UTC),
				"end_time":          time.Date(2016, 7, 1, 0, 0, 0, 0, time.UTC),
			},
			table.RowFixture{
				"track_id":          2,
				"question_id_order": "3|1|2",
				"start_time":        time.Date(2016, 6, 1, 0, 0, 0, 0, time.UTC),
				"end_time":          time.Date(2016, 7, 1, 0, 0, 0, 0, time.UTC),
			},
		},
		"questions": []table.RowFixture{
			table.RowFixture{
				"question_id": 1,
				"text":        "Text 1",
				"answer":      "Answer 1",
				"hint_one":    "hint 1",
				"hint_two":    "hint b1",
				"description": "Description 1",
				"is_enabled":  1,
			},
			table.RowFixture{
				"question_id": 2,
				"text":        "Text 2",
				"answer":      "Answer 2",
				"hint_one":    "hint 2",
				"hint_two":    "hint b2",
				"description": "Description 2",
				"is_enabled":  1,
			},
			table.RowFixture{
				"question_id": 3,
				"text":        "Text 3",
				"answer":      "Answer 3",
				"hint_one":    "hint 3",
				"hint_two":    "hint b3",
				"description": "Description 3",
				"is_enabled":  1,
			},
			table.RowFixture{
				"question_id": 4,
				"text":        "Text 4",
				"answer":      "Answer 4",
				"hint_one":    "hint 4",
				"hint_two":    "hint b4",
				"description": "Description 4",
				"is_enabled":  1,
			},
		},
		"team_progress": []table.RowFixture{
			table.RowFixture{
				"team_id":     1,
				"question_id": 1,
				"hint_cnt":    0,
			},
			table.RowFixture{
				"team_id":     1,
				"question_id": 2,
				"hint_cnt":    0,
			},
			table.RowFixture{
				"team_id":     22,
				"question_id": 3,
				"hint_cnt":    2,
				"answer_time": time.Date(2016, 6, 6, 13, 0, 0, 0, time.UTC),
			},
			table.RowFixture{
				"team_id":     20,
				"question_id": 2,
				"hint_cnt":    1,
				"answer_time": time.Date(2016, 6, 6, 13, 0, 0, 0, time.UTC),
			},
			table.RowFixture{
				"team_id":     20,
				"question_id": 3,
				"hint_cnt":    1,
			},
			table.RowFixture{
				"team_id":     21,
				"question_id": 2,
				"hint_cnt":    2,
				"answer_time": time.Date(2016, 6, 6, 13, 0, 0, 0, time.UTC),
			},
			table.RowFixture{
				"team_id":     21,
				"question_id": 3,
				"hint_cnt":    1,
				"answer_time": time.Date(2016, 6, 6, 13, 5, 0, 0, time.UTC),
			},
			table.RowFixture{
				"team_id":     21,
				"question_id": 4,
				"hint_cnt":    0,
			},
		},
		"hints": []table.RowFixture{
			table.RowFixture{
				"idx":         0,
				"question_id": 3,
				"hint":        "This is a hint 0",
			},
			table.RowFixture{
				"idx":         1,
				"question_id": 3,
				"hint":        "This is a hint 1",
			},
			table.RowFixture{
				"idx":         0,
				"question_id": 1,
				"hint":        "This is a hint 0 for quesiton 1",
			},
			table.RowFixture{
				"idx":         1,
				"question_id": 1,
				"hint":        "This is a hint 1 for quesiton 1",
			},
		},
	})
}