From 8d018d996c1eddb882dc64ebbd228bb0135944f3 Mon Sep 17 00:00:00 2001
From: sadbeast <sadbeast@sadbeast.com>
Date: Sun, 23 Jun 2024 15:36:59 -0700
Subject: wtf

---
 test/functions.sql | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 test/functions.sql

(limited to 'test/functions.sql')

diff --git a/test/functions.sql b/test/functions.sql
new file mode 100644
index 0000000..e7dbce2
--- /dev/null
+++ b/test/functions.sql
@@ -0,0 +1,38 @@
+BEGIN;
+SELECT plan(10);
+
+SELECT has_function('current_season');
+SELECT function_lang_is('current_season', 'sql');
+SELECT function_returns('current_season', 'integer');
+
+INSERT INTO seasons (started_at, ended_at) VALUES (NOW(), NOW() + interval '3 months');
+SELECT results_eq(
+    'SELECT current_season()',
+    'SELECT 1',
+    'should select a season'
+);
+
+SELECT has_function('category_score');
+SELECT function_lang_is('category_score', 'plpgsql');
+SELECT function_returns('category_score', 'smallint');
+
+SELECT results_eq(
+    $$SELECT category_score('win')$$,
+    'SELECT 1::smallint'
+);
+
+SELECT results_eq(
+    'SELECT category_score(''superbowl''),'
+        || 'category_score(''conference'')',
+    'SELECT 10::smallint, 10::smallint'
+);
+
+SELECT results_eq(
+    'SELECT category_score(''playoffs''), '
+        || 'category_score(''divisional''),'
+        || 'category_score(''champion'')',
+    'SELECT 5::smallint, 5::smallint, 5::smallint'
+);
+
+SELECT * FROM finish();
+ROLLBACK;
-- 
cgit v1.2.3

