File: 02_validate.t

package info (click to toggle)
libdebian-dep12-perl 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 124 kB
  • sloc: perl: 481; makefile: 2
file content (68 lines) | stat: -rw-r--r-- 2,021 bytes parent folder | download
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
#!/usr/bin/perl

use strict;
use warnings;
use Debian::DEP12;

use Test::More tests => 7;

my $entry;
my $warning;
my @warnings;

$entry = Debian::DEP12->new( <<END );
Bug-Database: https://github.com/merkys/Debian-DEP12/issues
Bug-Submit: https://github.com/merkys/Debian-DEP12/issues
END

@warnings = $entry->validate;
is( scalar @warnings, 0 );

$entry = Debian::DEP12->new( <<END );
Bug-Database: github.com/merkys/Debian-DEP12/issues
Bug-Submit:
END

@warnings = $entry->validate;
is( join( "\n", @warnings ) . "\n", <<'END' );
Bug-Database: value 'github.com/merkys/Debian-DEP12/issues' does not look like valid URL
Bug-Submit: undefined value
END

$entry = Debian::DEP12->new;
$entry->set( 'Bug-Database', 'github.com/merkys/Debian-DEP12/issues' );

@warnings = $entry->validate;
is( "@warnings", 'Bug-Database: value \'github.com/merkys/Debian-DEP12/issues\' does not look like valid URL' );

$entry = Debian::DEP12->new( <<END );
Reference:
  DOI: search for my surname and year
END

@warnings = $entry->validate;
is( "@warnings", 'Reference.DOI: value \'search for my surname and year\' does not look like valid DOI' );

$entry = Debian::DEP12->new( <<END );
Reference:
 - Year: 2021
 - DOI: search for my surname and year
END

@warnings = $entry->validate;
is( "@warnings", 'Reference[1].DOI: value \'search for my surname and year\' does not look like valid DOI' );

$entry = Debian::DEP12->new( { 'Bug-Submit' => 'merkys@cpan.org' } );
@warnings = $entry->validate;
is( "@warnings", 'Bug-Submit: value \'merkys@cpan.org\' is better written as \'mailto:merkys@cpan.org\'' );

$entry = Debian::DEP12->new(
    { 'Bug-Submit' => [ 'merkys@cpan.org',
                        'github.com/merkys/Debian-DEP12/issues' ] }
);
@warnings = $entry->validate;
is( join( "\n", @warnings ) . "\n", <<'END' );
Bug-Submit: scalar value expected
Bug-Submit[0]: value 'merkys@cpan.org' is better written as 'mailto:merkys@cpan.org'
Bug-Submit[1]: value 'github.com/merkys/Debian-DEP12/issues' does not look like valid URL
END