aboutsummaryrefslogtreecommitdiffstats
path: root/test/functions.sql
blob: e7dbce2b9fd20c56d3ad68c1a1e613dfafc38b21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;