-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added tests for network field validation
- Loading branch information
1 parent
7356ffb
commit d853899
Showing
4 changed files
with
264 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
-- SPDX-FileCopyrightText: © 2024 Adrian C. Prelipcean | ||
-- | ||
-- SPDX-License-Identifier: EUPL-1.2 | ||
create extension if not exists pgtfs; | ||
NOTICE: extension "pgtfs" already exists, skipping | ||
-- wrong trip id type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id::int, | ||
stop_id, | ||
arrival_time::double precision, | ||
departure_time::double precision, | ||
stop_sequence::int from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); | ||
ERROR: Expected text for trip ID, got integer | ||
-- wrong stop id type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id, | ||
stop_id::int, | ||
arrival_time::double precision, | ||
departure_time::double precision, | ||
stop_sequence::int from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); | ||
ERROR: Expected text for stop ID, got integer | ||
-- wrong arrival time type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id, | ||
stop_id, | ||
arrival_time::numeric, | ||
departure_time::double precision, | ||
stop_sequence::int from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); | ||
ERROR: Expected float8 for arrival time, got numeric | ||
-- wrong departure time type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id, | ||
stop_id, | ||
arrival_time::double precision, | ||
departure_time::numeric, | ||
stop_sequence::int from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); | ||
ERROR: Expected float8 for departure time, got numeric | ||
-- wrong stop sequence type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id, | ||
stop_id, | ||
arrival_time::double precision, | ||
departure_time::double precision, | ||
stop_sequence::text from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); | ||
ERROR: Expected integer for stop sequence, got text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SPDX-FileCopyrightText: © 2024 Adrian C. Prelipcean | ||
|
||
SPDX-License-Identifier: EUPL-1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
-- SPDX-FileCopyrightText: © 2024 Adrian C. Prelipcean | ||
-- | ||
-- SPDX-License-Identifier: EUPL-1.2 | ||
|
||
create extension if not exists pgtfs; | ||
|
||
-- wrong trip id type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id::int, | ||
stop_id, | ||
arrival_time::double precision, | ||
departure_time::double precision, | ||
stop_sequence::int from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); | ||
|
||
-- wrong stop id type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id, | ||
stop_id::int, | ||
arrival_time::double precision, | ||
departure_time::double precision, | ||
stop_sequence::int from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); | ||
|
||
-- wrong arrival time type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id, | ||
stop_id, | ||
arrival_time::numeric, | ||
departure_time::double precision, | ||
stop_sequence::int from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); | ||
|
||
-- wrong departure time type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id, | ||
stop_id, | ||
arrival_time::double precision, | ||
departure_time::numeric, | ||
stop_sequence::int from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); | ||
|
||
-- wrong stop sequence type | ||
select | ||
stop_id, | ||
stop_sequence, | ||
arrival_time, | ||
trip_id | ||
from pgtfs_csa( | ||
'1', '2', 1712707200.0, | ||
$$ | ||
select | ||
trip_id, | ||
stop_id, | ||
arrival_time::double precision, | ||
departure_time::double precision, | ||
stop_sequence::text from ( | ||
values | ||
('1753','1',NULL,1712757660,1), | ||
('1753','2',1712759880,1712759940,2), | ||
('1753','3',1712762040,1712762100,3), | ||
('1753','4',1712762100,NULL,4) | ||
) | ||
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); | ||
$$ | ||
); |