File: 04_source.t

package info (click to toggle)
libapt-pkg-perl 0.1.20
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 240 kB
  • ctags: 100
  • sloc: perl: 1,072; ansic: 198; makefile: 39
file content (95 lines) | stat: -rw-r--r-- 1,923 bytes parent folder | download | duplicates (3)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/perl

# $Id: 04_source.t,v 1.2 2004-06-20 11:19:53 bod Exp $
# AptPkg::Source tests

BEGIN { print "1..14\n" }

use AptPkg::Config '$_config';
use AptPkg::Source;

$_config->init;
$_config->read_file('t/cache/etc/apt.conf');
$_config->{quiet} = 0;

print "ok 1\n";

my $src = AptPkg::Source->new;

# cache created
unless ($src)
{
    print "not ok 2\n";
    exit;
}

sub check
{
    my ($test, $t) = @_;
    print 'not ' unless $t;
    print "ok $test\n";
}

# package "a" exists
if (my $a = $src->{a})
{
    print "ok 2\n";

    check 3, @$a == 1;

    $a = $a->[0];
    check 4, $a->{Package} eq 'a';
    check 5, $a->{Section} eq 'test';
    check 6, $a->{Version} eq '0.1';
    if ($a->{Binaries} and ref $a->{Binaries} eq 'ARRAY')
    {
    	check 7, "@{$a->{Binaries}}" eq 'a';
    }
    else
    {
    	print "not ok 7 # no binaries\n";
    }

    if ($a->{BuildDepends} and ref $a->{BuildDepends} eq 'HASH'
	and my $b = $a->{BuildDepends}{'Build-Depends'})
    {
	check  8, $b->[0][0] eq 'b';
	check  9, $b->[0][1] == AptPkg::Dep::GreaterEq;
	check 10, $b->[0][2] eq '0.2-42';
    }
    else
    {
	print "not ok 8 # build depends\n";
	print "ok $_ # skip\n" for 9..10;
    }

    if ($a->{Files} and ref $a->{Files} eq 'ARRAY')
    {
    	if (my ($dsc) = grep $_->{Type} eq 'dsc', @{$a->{Files}})
	{
	    check 11, $dsc->{ArchiveURI} =~ m!pool/main/a/a/a_0\.1\.dsc$!;
	    check 12, $dsc->{MD5Hash} eq '8202ae7d918948c192bdc0f183ab26ca';
	}
	else
	{
	    print "not ok 11 # no dsc\n";
	    print "ok 12 # skip\n";
	}

    	if (my ($tgz) = grep $_->{Type} eq 'tar', @{$a->{Files}})
	{
	    check 13, $tgz->{ArchiveURI} =~ m!pool/main/a/a/a_0\.1\.tar\.gz$!;
	    check 14, $tgz->{MD5Hash} eq 'a54a02be45314a8eea38058b9bbea7da';
	}
	else
	{
	    print "not ok 13 # no tar\n";
	    print "ok 14 # skip\n";
	}
    }
}
else
{
    print "not ok 2 # source a missing\n";
    print "ok $_ # skip\n" for 3..14;
}