add import_rep test
|
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
|
14 |
# Data directory |
fix tests
|
15 |
my $data_dir = $ENV{GITPREP_DATA_DIR} = "$FindBin::Bin/import_rep"; |
cleanup tests
|
16 | |
add import_rep test
|
17 |
# Test DB |
cleanup tests
|
18 |
my $db_file = "$data_dir/gitprep.db"; |
add import_rep test
|
19 | |
20 |
# Test Repository home |
|
cleanup tests
|
21 |
my $rep_home = "$data_dir/rep"; |
add import_rep test
|
22 | |
add need_login_always_option
|
23 |
$ENV{GITPREP_NO_MYCONFIG} = 1; |
24 | ||
add import_rep test
|
25 |
use Gitprep; |
26 | ||
27 |
note 'import_rep'; |
|
28 |
{ |
|
29 |
unlink $db_file; |
|
30 |
rmtree $rep_home; |
|
31 | ||
fix some tests
|
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
|
35 | |
add import_rep test
|
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...
|
41 |
$t->content_like(qr/Login page/); |
add import_rep test
|
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...
|
48 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', email => 'kimoto@foo.com', password => 'a', password2 => 'a'}); |
add import_rep test
|
49 |
$t->content_like(qr/Success.*created/); |
50 |
|
|
51 |
# Import repositories |
|
improve tests
|
52 |
my $rep_dir = "$FindBin::Bin/basic/rep/kimoto"; |
add import_rep test
|
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
|
60 |
ok(-f "$rep_home/kimoto/gitprep_t.git/refs/heads/b1"); |
add import_rep test
|
61 | |
62 |
# Tag |
|
cleanup xt tests
|
63 |
ok(-f "$rep_home/kimoto/gitprep_t.git/refs/tags/t1"); |
add import_rep test
|
64 |
|
65 |
# Description |
|
cleanup xt tests
|
66 |
ok(-f "$rep_home/kimoto/gitprep_t.git/description"); |
add import_rep test
|
67 |
} |
68 |