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
|
#!/usr/bin/env perl
# Some tests for 'darcs push'
use lib 'lib/perl';
use Test::More tests => 7;
use Test::Darcs;
use Shell::Command;
use strict;
use File::Temp 'tempdir';
chdir tempdir( CLEANUP => 1 );
mkpath 'temp1';
mkpath 'temp2/one/two';
chdir 'temp1';
darcs 'init';
chdir '../temp2';
darcs 'init';
chdir '../';
{
my $test_name = 'push without a repo gives an error';
chdir './temp1';
my $out = darcs qw/push -p 123/;
like($out,qr/missing argument/i,$test_name);
chdir '../';
}
{
chdir './temp2/one/two';
my $test_name = 'darcs push should work relative to the current directory';
my $push_out = darcs qw!push -a ../../../temp1!;
like($push_out, qr/No recorded local changes to push/i, $test_name);
chdir '../../../'; # above temp repos
}
{
my $test_name = 'darcs push should push into repo specified with --repo';
chdir './temp2';
darcs 'add one';
darcs "record --patch-name 'uno' --all";
chdir '../'; # now outside of any repo
like(darcs(qw!push --repodir temp2 --all "../temp1"!), # temp2 is relative to temp1
qr/Finished apply./i, $test_name);
}
SELF_PUSH: {
chdir './temp1';
my $default_repo_pre_test = 'Before trying to pull from self, defaultrepo does not exist';
ok( (! -r './_darcs/prefs/defaultrepo'),$default_repo_pre_test);
my $test_name = 'return special message when you try to push to yourself';
use Cwd;
like( darcs(qw/push -a/,getcwd()), qr/Can't push to current repository!/i, $test_name);
like( darcs(qw/push -a ./), qr/Can't push to current repository!/i, $test_name);
my $set_default_repo_test = "and don't update the default repo to be the current dir";
ok( (! -r './_darcs/prefs/defaultrepo'),$set_default_repo_test);
chdir '../'; # now outside of any repo
}
|