diff options
Diffstat (limited to 'test/db/scores.sql')
-rw-r--r-- | test/db/scores.sql | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/db/scores.sql b/test/db/scores.sql new file mode 100644 index 0000000..2e1fee3 --- /dev/null +++ b/test/db/scores.sql @@ -0,0 +1,19 @@ +BEGIN; +SELECT plan(2); + +SELECT has_table('scores'); +SELECT has_table('score_categories'); + +SELECT league_id AS nfl_league_id FROM leagues WHERE name = 'NFL' LIMIT 1 \gset +INSERT INTO seasons (league_id, started_at, ended_at) VALUES (:nfl_league_id, now() - interval '1 day', now() + interval '3 months') RETURNING season_id new_season_id \gset + +SELECT league_id AS nfl_league_id FROM leagues WHERE name = 'NFL' LIMIT 1 \gset +SELECT team_id AS seattle FROM teams JOIN league_divisions USING (league_division_id) WHERE teams.name = 'Seattle' AND league_id = :nfl_league_id \gset +SELECT team_id AS buffalo FROM teams JOIN league_divisions USING (league_division_id) WHERE teams.name = 'Buffalo' AND league_id = :nfl_league_id \gset + +SELECT record_score(:seattle, 1, :new_season_id, 1, now()); +SELECT record_score(:seattle, 2, :new_season_id, 1, now()); +SELECT record_score(:buffalo, 2, :new_season_id, 1, now()); + +SELECT * FROM finish(); +ROLLBACK; |