gitprep / xt / import_rep.t /
Newer Older
68 lines | 1.696kb
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

            
cleanup tests
Yuki Kimoto authored on 2016-04-14
14
# Data directory
fix tests
Yuki Kimoto authored on 2016-04-14
15
my $data_dir =  $ENV{GITPREP_DATA_DIR} = "$FindBin::Bin/import_rep";
cleanup tests
Yuki Kimoto authored on 2016-04-14
16

            
add import_rep test
Yuki Kimoto authored on 2013-08-20
17
# Test DB
cleanup tests
Yuki Kimoto authored on 2016-04-16
18
my $db_file = "$data_dir/gitprep.db";
add import_rep test
Yuki Kimoto authored on 2013-08-20
19

            
20
# Test Repository home
cleanup tests
Yuki Kimoto authored on 2016-04-16
21
my $rep_home = "$data_dir/rep";
add import_rep test
Yuki Kimoto authored on 2013-08-20
22

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

            
add import_rep test
Yuki Kimoto authored on 2013-08-20
25
use Gitprep;
26

            
27
note 'import_rep';
28
{
29
  unlink $db_file;
30
  rmtree $rep_home;
31

            
fix some tests
Yuki Kimoto authored on 2016-04-21
32
  system("$FindBin::Bin/../setup_database", $db_file) == 0
33
    or die "Can't setup $db_file";
34
  my $app = Mojo::Server->new->load_app("$FindBin::Bin/../script/gitprep");
cleanup tests
Yuki Kimoto authored on 2016-04-14
35

            
add import_rep test
Yuki Kimoto authored on 2013-08-20
36
  my $t = Test::Mojo->new($app);
37
  $t->ua->max_redirects(3);
38
  
39
  # Create admin user
40
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
remove need_login_always opt...
Yuki Kimoto authored on 2013-08-22
41
  $t->content_like(qr/Login page/);
add import_rep test
Yuki Kimoto authored on 2013-08-20
42

            
43
  # Login as admin
44
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'});
45
  $t->content_like(qr/Admin/);
46

            
47
  # Create user
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
48
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', email => 'kimoto@foo.com', password => 'a', password2 => 'a'});
add import_rep test
Yuki Kimoto authored on 2013-08-20
49
  $t->content_like(qr/Success.*created/);
50
  
51
  # Import repositories
improve tests
Yuki Kimoto authored on 2016-04-14
52
  my $rep_dir = "$FindBin::Bin/basic/rep/kimoto";
add import_rep test
Yuki Kimoto authored on 2013-08-20
53
  chdir "$FindBin::Bin/../script"
54
    or die "Can't change directory: $!";
55
  my @cmd = ('./import_rep', '-u', 'kimoto', $rep_dir);
56
  system(@cmd) == 0
57
    or die "Command fail: @cmd";
58
  
59
  # Branch
cleanup xt tests
Yuki Kimoto authored on 2016-04-14
60
  ok(-f "$rep_home/kimoto/gitprep_t.git/refs/heads/b1");
add import_rep test
Yuki Kimoto authored on 2013-08-20
61

            
62
  # Tag
cleanup xt tests
Yuki Kimoto authored on 2016-04-14
63
  ok(-f "$rep_home/kimoto/gitprep_t.git/refs/tags/t1");
add import_rep test
Yuki Kimoto authored on 2013-08-20
64
  
65
  # Description
cleanup xt tests
Yuki Kimoto authored on 2016-04-14
66
  ok(-f "$rep_home/kimoto/gitprep_t.git/description");
add import_rep test
Yuki Kimoto authored on 2013-08-20
67
}
68