diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-01-31 23:44:17 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-01-31 23:44:17 -0700 |
commit | a99a0e9e9f8cf83e7e1e41a4b4ac49a32ca76ee4 (patch) | |
tree | 5854d4297c69a437526a2422dc373630e12acdc2 /t | |
download | p5-Git-Annex-a99a0e9e9f8cf83e7e1e41a4b4ac49a32ca76ee4.tar.gz |
basic Git::Annex wrapper class and project administrivia
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 't')
-rwxr-xr-x | t/10_init.t | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/t/10_init.t b/t/10_init.t new file mode 100755 index 0000000..02e284c --- /dev/null +++ b/t/10_init.t @@ -0,0 +1,55 @@ +#!/usr/bin/perl + +use 5.028; +use strict; +use warnings; + +use Test::More; +use Git::Annex; +use File::chdir; +use File::Slurp; +use File::Temp qw(tempdir); + +{ + my $temp = tempdir CLEANUP => 1; + my $annex = Git::Annex->new($temp); + ok $annex->toplevel eq $temp, "constructor sets toplevel to provided dir"; + local $CWD = $temp; + $annex = Git::Annex->new; + ok $annex->toplevel eq $temp, "constructor sets toplevel to pwd"; +} + +{ + my $temp = tempdir CLEANUP => 1; + my $annex = Git::Annex->new($temp); + ok !defined $annex->{git}, "Git::Wrapper instance lazily instantiated"; + ok $annex->git->isa("Git::Wrapper") && defined $annex->{git}, + "Git::Wrapper instance available"; + ok $annex->git->dir eq $temp, "Git::Wrapper has correct toplevel"; +} + +# lazy init of Git::Repository object requires an actual git repo, not +# just an empty tempdir +with_temp_annex(sub { + my $temp = shift; + my $annex = Git::Annex->new($temp); + ok !defined $annex->{repo}, "Git::Repository instance lazily instantiated"; + ok $annex->repo->isa("Git::Repository") && defined $annex->{repo}, + "Git::Repository instance available"; + ok $annex->repo->work_tree eq $temp, "Git::Repository has correct toplevel"; +}); + +sub with_temp_annex { + my $temp = tempdir CLEANUP => 1; + { + local $CWD = $temp; + system qw(git init); + system qw(git annex init); + write_file "foo", "my cool big file\n"; + system qw(git annex add foo); + system qw(git commit -madd); + } + &{$_[0]}($temp); +} + +done_testing; |