Throw a bit more Moose around, and copy config to model so that we can test (and...
[catagits/Gitalist.git] / t / model_Git.t
1 use strict;
2 use warnings;
3 use FindBin qw/$Bin/;
4 use Test::More qw/no_plan/;
5
6 BEGIN { use_ok 'Gitalist::Model::Git' }
7
8 my $c = bless {}, 'Gitalist';
9 my $Git = Gitalist::Model::Git->new($c, { repo_dir => "$Bin/lib/repositories" });
10
11 # 'bare.git' is a bare git repository in the repository dir
12 use Path::Class;
13 my $repoBare = Path::Class::Dir->new('t/lib/repositories/bare.git');
14 ok( $Git->is_git_repo( $repoBare ), 'is_git_repo true for bare git repo' );
15
16 # 'working' is a working copy w/ git repo in the repository dir
17 my $repoWorking = Path::Class::Dir->new('t/lib/repositories/working');
18 #ok( $Git->is_git_repo( $repoWorking ), 'is_git_repo true for git repo in working copy' );
19
20 # 'empty.git' is an empty directory in the repository dir
21 my $repoEmpty = Path::Class::Dir->new('t/lib/repositories/empty.git');
22 ok( ! $Git->is_git_repo( $repoEmpty ), 'is_git_repo is false for empty dir' );
23
24 my $projectList = $Git->list_projects;
25 ok( scalar @{$projectList} == 1, 'list_projects returns an array with the correct number of members' );
26 ok( $projectList->[0]->{name} eq 'bare.git', 'list_projects has correct name for "bare.git" repo' );
27 #ok( $projectList->[1]->{name} eq 'working/.git', 'list_projects has correct name for "working" repo' );
28
29 use Data::Dumper;
30 #warn( Dumper($projectList) );
31