summaryrefslogtreecommitdiffstats
path: root/test/t/salsa.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:36:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:36:25 +0000
commit6077d258b500b20e1e705f5cda567400240c7804 (patch)
treea5d41c050bd69f91476994b0d30c0a8f1e7957b5 /test/t/salsa.t
parentInitial commit. (diff)
downloaddevscripts-6077d258b500b20e1e705f5cda567400240c7804.tar.xz
devscripts-6077d258b500b20e1e705f5cda567400240c7804.zip
Adding upstream version 2.21.3+deb11u1.upstream/2.21.3+deb11u1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/t/salsa.t')
-rw-r--r--test/t/salsa.t108
1 files changed, 108 insertions, 0 deletions
diff --git a/test/t/salsa.t b/test/t/salsa.t
new file mode 100644
index 0000000..d80978a
--- /dev/null
+++ b/test/t/salsa.t
@@ -0,0 +1,108 @@
+#!/usr/bin/env perl
+
+my $skip;
+use File::Temp 'tempdir';
+use Test::More;
+use strict;
+
+BEGIN {
+ eval "use Test::Output;use GitLab::API::v4;";
+ $skip = $@ ? 1 : 0;
+}
+
+my $pwd = `pwd`;
+chomp $pwd;
+my ($api, $gitdir);
+
+sub mkDebianDir {
+ my $tmpdir = tempdir(CLEANUP => 1);
+ chdir $tmpdir;
+ $ENV{"GIT_CONFIG_NOGLOBAL"} = 1;
+ $ENV{"HOME"} = "";
+ system "git init";
+ system "git config user.name 'Joe Developer'";
+ system 'git config user.email "jd@debian.org"';
+ 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'";
+ system "git checkout -q -b dev";
+ chdir $pwd;
+ return $tmpdir;
+}
+
+sub run {
+ my ($result, $out, @list) = @_;
+ @ARGV = ('--no-cache', @list);
+ my ($res, $salsa);
+ combined_like(
+ sub {
+ $salsa = Devscripts::Salsa->new({ api => $api });
+ $salsa->config->git_server_url($gitdir . '/');
+ $res = $salsa->run;
+ },
+ $out,
+ "command: " . join(' ', @list));
+ ok($res =~ /^$result$/i, " result is $result");
+}
+
+sub run_debug {
+ my ($result, $out, @list) = @_;
+ @ARGV = ('--no-cache', @list);
+ my ($res, $salsa);
+ $salsa = Devscripts::Salsa->new({ api => $api });
+ $salsa->config->git_server_url($gitdir . '/');
+ $res = $salsa->run;
+}
+
+SKIP: {
+ skip "Missing dependencies" if ($skip);
+ require './t/salsa.pm';
+ $gitdir = tempdir(CLEANUP => 1);
+ sleep 1;
+ mkdir "$gitdir/me" or die "$gitdir/me: $!";
+
+ $api = api($gitdir);
+
+ use_ok 'Devscripts::Salsa';
+ $Devscripts::Output::die_on_error = 0;
+ @Devscripts::Config::config_files = ('t/salsa.conf');
+
+ # Search methods
+ run(0, qr/Id\s*:\s*11\nUsername\s*:\s*me/s, 'whoami');
+ run(0, qr/Id\s*:\s*2099\nName/s, 'search_group', 'js-team');
+ run(0, qr/Id\s*:\s*2099\nName/s, 'search_group', 2099);
+ run(0, qr/Id.*\nUsername\s*: me/s, 'search_user', 'me');
+ run(0, qr/Id.*\nUsername\s*: me/s, 'search_user', 'm');
+ run(0, qr/Id.*\nUsername\s*: me/s, 'search_user', 11);
+
+ # Project methods
+ my $repo = mkDebianDir;
+ run(0, qr/Project .*created/s, '-C', $repo, '--verbose', 'push_repo', '.');
+ chdir $pwd;
+ $repo = tempdir(CLEANUP => 1);
+ run(0, qr/KGB hook added.*Tagpending hook added/s,
+ 'update_repo', '--kgb', '--irc=debian', '--tagpending', 'foobar');
+ run(0, qr/foobar\s*:\s*OK/s,
+ 'update_safe', '--kgb', '--irc=debian', '--tagpending', 'foobar');
+ run(0, qr{Full path\s*:\s*me/foobar}, 'search', 'foobar');
+ run(0, qr{Configuring foobar},
+ 'rename_branch', 'foobar', '--source-branch=dev',
+ '--dest-branch=dev2');
+}
+
+done_testing;
+
+1;