Files
threshold/internal/db/sqltest/tests/controller/controller_id.sql
T
Louis Ruch 4cacd0a605 bug(scheduler): Fix controller id length check (#2226)
* bug(scheduler): Fix controller id length check

The job_run table has a foreign key to the server_controller private_id.
While this column is called a prviate_id it does not implement the wt_private_id
postgres domain type, and therefore does not have a minimum length of 10 characters.
2022-06-22 13:20:27 -07:00

34 lines
1.0 KiB
PL/PgSQL

-- controller_id tests:
-- validates the wt_controller_id domain
begin;
select plan(8);
select has_domain('wt_controller_id');
create table controller_id_testing (
id wt_controller_id
);
prepare empty_insert as insert into controller_id_testing (id) values ('');
SELECT throws_like(
'empty_insert',
'%"wt_controller_id_check"',
'We should error for empty controller id'
);
prepare null_insert as insert into controller_id_testing (id) values (null);
select lives_ok('null_insert');
select is(count(*), 1::bigint) from controller_id_testing where id is null;
prepare valid_insert as insert into controller_id_testing (id) values ('test-controller-id');
select lives_ok('valid_insert');
select is(count(*), 1::bigint) from controller_id_testing where id = 'test-controller-id';
prepare short_insert as insert into controller_id_testing (id) values ('_');
select lives_ok('short_insert');
select is(count(*), 1::bigint) from controller_id_testing where id = '_';
select * from finish();
rollback;