BEGIN;
SELECT plan(4);

SELECT has_table('leagues');

SELECT columns_are('leagues', ARRAY[ 'league_id', 'name', 'user_id', 'modified_at', 'created_at']);

SELECT has_sequence('leagues_league_id_seq');

SELECT has_index('teamdraft', 'leagues', 'leagues_pk', 'league_id');

\set new_user_id 5 
INSERT INTO users(user_id, username) OVERRIDING SYSTEM VALUE VALUES (5, 'test'); 
\set new_league_id 5 
INSERT INTO leagues(league_id, name, user_id) OVERRIDING SYSTEM VALUE VALUES (:new_league_id, 'test league', :new_user_id);

CALL new_league_season(:new_league_id);

SELECT * FROM finish();
ROLLBACK;

