-- Test weather_forecast
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;

begin;

select plan(31);

set search_path to camper, public;

select has_table('weather_forecast');
select has_pk('weather_forecast');
select table_privs_are('weather_forecast', 'guest', array['SELECT']);
select table_privs_are('weather_forecast', 'employee', array['SELECT']);
select table_privs_are('weather_forecast', 'admin', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
select table_privs_are('weather_forecast', 'authenticator', array[]::text[]);

select has_column('weather_forecast', 'station_uri');
select col_is_pk('weather_forecast', 'station_uri');
select col_type_is('weather_forecast', 'station_uri', 'uri');
select col_not_null('weather_forecast', 'station_uri');
select col_hasnt_default('weather_forecast', 'station_uri');

select has_column('weather_forecast', 'forecasted_at');
select col_type_is('weather_forecast', 'forecasted_at', 'timestamp with time zone');
select col_not_null('weather_forecast', 'forecasted_at');
select col_hasnt_default('weather_forecast', 'forecasted_at');

select has_column('weather_forecast', 'weather_condition_id');
select col_type_is('weather_forecast', 'weather_condition_id', 'text');
select col_not_null('weather_forecast', 'weather_condition_id');
select col_hasnt_default('weather_forecast', 'weather_condition_id');

select has_column('weather_forecast', 'day_temperature');
select col_type_is('weather_forecast', 'day_temperature', 'numeric(5,2)');
select col_not_null('weather_forecast', 'day_temperature');
select col_hasnt_default('weather_forecast', 'day_temperature');

select has_column('weather_forecast', 'min_temperature');
select col_type_is('weather_forecast', 'min_temperature', 'numeric(5,2)');
select col_not_null('weather_forecast', 'min_temperature');
select col_hasnt_default('weather_forecast', 'min_temperature');

select has_column('weather_forecast', 'updated_at');
select col_type_is('weather_forecast', 'updated_at', 'timestamp with time zone');
select col_not_null('weather_forecast', 'updated_at');
select col_hasnt_default('weather_forecast', 'updated_at');


select *
from finish();

rollback;

