summaryrefslogtreecommitdiff
path: root/t/30-iris-const.t
blob: aed46ef93786d72c88ea638c672ee8af9fa10dee (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env perl
use strict;
use warnings;
use 5.014;

use DateTime;
use Test::More tests => 5;
use Test::Fatal;

use Travel::Status::DE::IRIS;

my $status = Travel::Status::DE::IRIS->new(
	iris_base => 'file:t/in',
	station   => 'EE',
	datetime  => DateTime->new(
		year      => 2014,
		month     => 1,
		day       => 3,
		hour      => 20,
		minute    => 1,
		time_zone => 'Europe/Berlin'
	)
);

is( $status->errstr, undef, 'constructor with data for everything' );

$status = Travel::Status::DE::IRIS->new(
	iris_base => 'file:t/in',
	station   => 'EE',
	datetime  => DateTime->new(
		year      => 2014,
		month     => 1,
		day       => 3,
		hour      => 19,
		minute    => 1,
		time_zone => 'Europe/Berlin'
	)
);

ok( defined $status->warnstr, 'constructor with missing data has warnstr' );

$status = Travel::Status::DE::IRIS->new(
	iris_base => 'file:t/in',
	station   => 'doesnotexist',
	datetime  => DateTime->new(
		year      => 2014,
		month     => 1,
		day       => 3,
		hour      => 19,
		minute    => 1,
		time_zone => 'Europe/Berlin'
	)
);

ok( defined $status->errstr, 'constructor with imaginary station has errstr' );

$status = Travel::Status::DE::IRIS->new(
	iris_base => 'file:t/in',
	station   => 'EBILP',
	datetime  => DateTime->new(
		year      => 2014,
		month     => 1,
		day       => 3,
		hour      => 20,
		minute    => 1,
		time_zone => 'Europe/Berlin'
	)
);

like(
	$status->errstr,
	qr{no associated timetable},
	'constructor with bad station has errstr'
);

ok(
	exception {
		$status = Travel::Status::DE::IRIS->new( iris_base => 'file:t/in' );
	},
	'station parameter is mandatory -> code dies if missing'
);