gitprep / xt / import_rep.t /
Newer Older
62 lines | 1.584kb
add import_rep test
Yuki Kimoto authored on 2013-08-20
1
use Test::More 'no_plan';
2
use strict;
3
use warnings;
4

            
5
use FindBin;
6
use utf8;
7
use lib "$FindBin::Bin/../lib";
8
use lib "$FindBin::Bin/../extlib/lib/perl5";
9
use File::Path 'rmtree';
10
use Encode qw/encode decode/;
11

            
12
use Test::Mojo;
13

            
14
# Test DB
15
my $db_file = $ENV{GITPREP_DB_FILE} = "$FindBin::Bin/import_rep.db";
16

            
17
# Test Repository home
18
my $rep_home = $ENV{GITPREP_REP_HOME} = "$FindBin::Bin/import_rep_user";
19

            
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
20
$ENV{GITPREP_NO_MYCONFIG} = 1;
21

            
add import_rep test
Yuki Kimoto authored on 2013-08-20
22
use Gitprep;
23

            
24
note 'import_rep';
25
{
26
  unlink $db_file;
27
  rmtree $rep_home;
28

            
29
  my $app = Gitprep->new;
30
  my $t = Test::Mojo->new($app);
31
  $t->ua->max_redirects(3);
32
  
33
  # Create admin user
34
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
remove need_login_always opt...
Yuki Kimoto authored on 2013-08-22
35
  $t->content_like(qr/Login page/);
add import_rep test
Yuki Kimoto authored on 2013-08-20
36

            
37
  # Login as admin
38
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'});
39
  $t->content_like(qr/Admin/);
40

            
41
  # Create user
42
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'});
43
  $t->content_like(qr/Success.*created/);
44
  
45
  # Import repositories
46
  my $rep_dir = "$FindBin::Bin/../../gitprep_t_rep_home/kimoto";
47
  chdir "$FindBin::Bin/../script"
48
    or die "Can't change directory: $!";
49
  my @cmd = ('./import_rep', '-u', 'kimoto', $rep_dir);
50
  system(@cmd) == 0
51
    or die "Command fail: @cmd";
52
  
53
  # Branch
54
  ok(-f "$FindBin::Bin/import_rep_user/kimoto/gitprep_t.git/refs/heads/b1");
55

            
56
  # Tag
57
  ok(-f "$FindBin::Bin/import_rep_user/kimoto/gitprep_t.git/refs/tags/t1");
58
  
59
  # Description
60
  ok(-f "$FindBin::Bin/import_rep_user/kimoto/gitprep_t.git/description");
61
}
62