summaryrefslogtreecommitdiffstats
path: root/test/db/scores.sql
diff options
context:
space:
mode:
authorsadbeast <sadbeast@sadbeast.com>2024-07-16 18:16:29 -0700
committersadbeast <sadbeast@sadbeast.com>2024-10-05 16:40:55 -0700
commit6bd24af2ffbea91db1b10a5d5258980ce2068c7f (patch)
tree66634833f2d45260be5fcaf9111400eda12f03cc /test/db/scores.sql
downloadteamdraft-6bd24af2ffbea91db1b10a5d5258980ce2068c7f.tar.gz
teamdraft-6bd24af2ffbea91db1b10a5d5258980ce2068c7f.tar.bz2
let's goHEADmain
Diffstat (limited to 'test/db/scores.sql')
-rw-r--r--test/db/scores.sql19
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;