summaryrefslogtreecommitdiffabout
path: root/t/request.t
blob: 3880229e22f0d6d8bb9deffdb76ec792ed613a99 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# -*- perl -*-
use lib qw(t lib);
use strict;
use warnings;
use SlackBuild::Request;
use SlackBuild::Info;
use File::Temp;
use Test;

plan tests => 6;

#1
my $req = new SlackBuild::Request(
    package => 'foo',
    version => '1.0',
    slackbuild_uri => 'foo.tar.gz',
    source_uri => 'foo-1.0.tar.gz',
    prereq => [qw(bar baz)],
);

ok("$req",
   q{{"package":"foo","prereq":["bar","baz"],"slackbuild_uri":"foo.tar.gz","source_uri":["foo-1.0.tar.gz"],"version":"1.0"}});

#2
$req = new SlackBuild::Request(slackbuild_uri => 'foo.tar.gz');

my $infostr = <<'EOT';
PRGNAM="foo"
VERSION="1.1"
DOWNLOAD="foo-1.1.tar.gz bar-1.0.tar.gz"
EOT
;

$req->addinfo(new SlackBuild::Info(\$infostr));
ok("$req",
   q{{"package":"foo","slackbuild_uri":"foo.tar.gz","source_uri":["foo-1.1.tar.gz","bar-1.0.tar.gz"],"version":"1.1"}});

#3
$req = new SlackBuild::Request(
    package => 'foo',
    version => '1.0',
    slackbuild_uri => 'foo.tar.gz',
    source_uri => 'foo-1.0.tar.gz',
    prereq => [qw(bar baz)]
);

$infostr = <<'EOT';
PRGNAM="foo11"
VERSION="1.1"
DOWNLOAD="foo-1.1.tar.gz"
REQUIRES="%README% quux quuZ"  
EOT
;

$req->addinfo(new SlackBuild::Info(\$infostr));

ok("$req",
   q{{"package":"foo","prereq":["bar","baz","quux","quuZ"],"slackbuild_uri":"foo.tar.gz","source_uri":["foo-1.0.tar.gz"],"version":"1.0"}});

#4
$req = new SlackBuild::Request(
    package => 'foo',
    version => '1.0',
    slackbuild_uri => 'foo.tar.gz',
    source_uri => 'foo-1.0.tar.gz',
    prereq => [qw(bar baz)],
    strategy => { prereq => 'overwrite' }
);

$req->addinfo(new SlackBuild::Info(\$infostr));

ok("$req",
   q{{"package":"foo","prereq":["quux","quuZ"],"slackbuild_uri":"foo.tar.gz","source_uri":["foo-1.0.tar.gz"],"strategy":{"prereq":"overwrite"},"version":"1.0"}});

#5
$req = new SlackBuild::Request(
    package => 'foo',
    version => '1.0',
    slackbuild_uri => 'foo.tar.gz',
    source_uri => 'foo-1.0.tar.gz',
    prereq => [qw(bar baz)],
    strategy => { prereq => 'keep' }
);

$req->addinfo(new SlackBuild::Info(\$infostr));

ok("$req",
   q{{"package":"foo","prereq":["bar","baz"],"slackbuild_uri":"foo.tar.gz","source_uri":["foo-1.0.tar.gz"],"strategy":{"prereq":"keep"},"version":"1.0"}});

#6
my $fh = new File::Temp(UNLINK => 1);
print $fh <<'EOT'
{
    "package": "foo",
    "version": "1.0",
    "source_uri": ["foo-1.1.tar.gz","bar-1.0.tar.gz"],
    "build":"2",
    "prereq": "quux"
}
EOT
;
$fh->flush;
$req = new SlackBuild::Request($fh->filename);
ok("$req",
   q{{"build":"2","package":"foo","prereq":["quux"],"source_uri":["foo-1.1.tar.gz","bar-1.0.tar.gz"],"version":"1.0"}});


Return to:

Send suggestions and report system problems to the System administrator.