-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
126 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env perl | ||
|
||
use v5.12.5; | ||
use warnings; | ||
|
||
our $VERSION = '9999.99.99_99'; # VERSION | ||
|
||
use Test::More tests => 5; | ||
use Test::Exception; | ||
|
||
use File::Spec; | ||
use File::Temp qw(tempdir); | ||
use Rex::Commands; | ||
use Rex::Commands::Run; | ||
use Rex::Commands::SCM; | ||
use Rex::Helper::Run; | ||
|
||
$::QUIET = 1; | ||
|
||
my $git = can_run('git'); | ||
|
||
if ( !defined $git ) { | ||
plan skip_all => 'Can not find git command'; | ||
} | ||
|
||
ok( $git, "Found git command at $git" ); | ||
|
||
my $git_version = i_run "$git version"; | ||
ok( $git_version, qq(Git version returned as '$git_version') ); | ||
|
||
my $test_repo_dir = tempdir( CLEANUP => 1 ); | ||
ok( -d $test_repo_dir, "$test_repo_dir is the test repo directory now" ); | ||
|
||
prepare_test_repo($test_repo_dir); | ||
|
||
subtest 'clone into existing directory', sub { | ||
plan tests => 3; | ||
|
||
my $test_repo_name = 'test_repo'; | ||
my $clone_target_dir = tempdir( CLEANUP => 1 ); | ||
|
||
set repository => $test_repo_name, url => "file://$test_repo_dir"; | ||
|
||
ok( -d $clone_target_dir, | ||
"$clone_target_dir is the clone target directory now" ); | ||
|
||
lives_ok { checkout $test_repo_name, path => $clone_target_dir } | ||
'cloning into to existing directory'; | ||
|
||
git_repo_ok($clone_target_dir); | ||
}; | ||
|
||
sub prepare_test_repo { | ||
my $directory = shift; | ||
|
||
i_run 'git init', cwd => $directory; | ||
|
||
git_repo_ok($directory); | ||
|
||
i_run q(git config user.name 'Rex Test Suite'), cwd => $directory; | ||
i_run q(git config user.email 'noreply@rexify.org'), cwd => $directory; | ||
|
||
i_run q(git commit --allow-empty -m 'Initial commit'), cwd => $directory; | ||
|
||
return; | ||
} | ||
|
||
sub git_repo_ok { | ||
my $directory = shift; | ||
|
||
ok( | ||
-d File::Spec->join( $directory, '.git' ), | ||
"$directory looks like a git repository now" | ||
); | ||
|
||
return; | ||
} |