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
|
#!/usr/bin/perl
use strict;
use lib '../lib';
use Test::More;
my $skip;
BEGIN {
my $cwd = `pwd`;
chomp $cwd;
eval "use File::Temp 'tempdir';"
. "use Test::Output;use GitLab::API::v4;"
. "use lib '$cwd/../lib'";
$skip = $@ ? 1 : 0;
}
sub run {
my ($result, $out, @list) = @_;
@ARGV = @list;
my $res;
combined_like(
sub {
$res = Devscripts::Salsa->new->run;
},
$out,
"command: " . join(' ', @list));
ok($res =~ /^$result$/i, " result is $result");
}
sub mkDebianDir {
my $tmpdir = tempdir(CLEANUP => 1);
chdir $tmpdir;
$ENV{"GIT_CONFIG_NOGLOBAL"} = 1;
system "git init";
mkdir 'debian';
open F, ">debian/changelog";
print F <<EOF;
foobar (0-1) unstable; urgency=low
* Initial release
-- Joe Developer <jd\@debian.org> Mon, 02 Nov 2013 22:21:31 -0100
EOF
close F;
open F, ">README.md";
print F <<EOF;
# Salsa test
EOF
system "git add *";
system "git commit -a -m 'Salsa test'";
}
SKIP: {
skip "Missing dependencies" if ($skip);
use_ok 'Devscripts::Salsa';
$Devscripts::Output::die_on_error = 0;
# Search methods
run(0, qr/Id.*\nUsername.*/s, 'whoami');
run(0, qr/Id.*\nName/s, 'search_group', 'js-team');
run(0, qr/Id.*\nName/s, 'search_group', '2666');
run(0, qr/Id.*\nName/s, 'search_group', 'perl-team/modules');
run(0, qr/Id.*\nUsername\s*: yadd/s, 'search_user', 'yadd');
run(0, qr/Id.*\nUsername\s*: yadd/s, 'search_user', 'yad');
run(0, qr/Id.*\nUsername\s*: yadd/s, 'search_user', '3818');
run(0, qr/Id.*\nName\s*: qa/s, 'search_project', 'qa');
run(0, qr/Id.*\nName\s*: qa/s, 'search_project', '1417');
run(0, qr/Id.*\nName\s*: qa/s, 'search_project', 'qa/qa');
run(0, qr/Id.*\nUsername.*/s, '--group', 'perl-team', 'group');
run(0, qr/Id.*\nName/s, '--group', 'perl-team', 'list_repos');
run(0, qr/Id.*\nName/s, 'list_groups');
run(0, qr/Id.*\n\tName/s, 'forks', 'qa/qa');
run(0, qr/^debian\/devscripts/m, 'mrs', 'debian/devscripts');
run(0, qr/^devscripts/m, 'mrs', 'devscripts', '--group-id', 2);
run(0, qr/master.*Maintainer.*Developers/m,
'protected_branches', 'debian/devscripts');
# checkout
{
my $tmpdir = tempdir(CLEANUP => 1);
run(0, qr/gbp:info/, 'co', '-C', $tmpdir,
'debian/libapache2-mod-fcgid');
ok(
-d "$tmpdir/libapache2-mod-fcgid/.git",
' libapache2-mod-fcgid cloned'
);
run(0, qr/gbp:info/, 'checkout', '-C', $tmpdir, '--group=qa', 'qa');
ok(-d "$tmpdir/qa/.git", ' qa cloned');
}
# push_repo, update_repo and del_repo
if ($ARGV[0] eq '--full') {
mkDebianDir;
run(0, qr/Project .*created/s,
'push_repo', '.', '--verbose', '--kgb', '--irc=devscripts');
diag "Verify that foobar appears in #devscripts channel";
run(0, qr/Project .*updated/s,
'update_repo', 'foobar', '--rename-head');
run(1, qr/update_repo has failed for foobar/s,
'update_repo', 'foobar', '--rename-head', '--no-fail');
run(0, qr/Project .*foobar deleted/s,
'--verbose', 'del_repo', 'foobar');
}
}
done_testing;
|