... | ... |
@@ -33,3 +33,6 @@ xt/admin |
33 | 33 |
xt/user.db |
34 | 34 |
xt/user |
35 | 35 |
xt/log |
36 |
+xt/import_rep.db |
|
37 |
+xt/import_rep_user |
|
38 |
+ |
... | ... |
@@ -90,7 +90,7 @@ for my $rep (glob "$rep_dir/*") { |
90 | 90 |
# Push repository |
91 | 91 |
chdir $rep |
92 | 92 |
or warn "Can't change directory $rep: $!\n"; |
93 |
- my $remote_rep = "$FindBin::Bin/../data/rep/$user/$project.git"; |
|
93 |
+ my $remote_rep = $git->rep($user, $project); |
|
94 | 94 |
|
95 | 95 |
# push branches |
96 | 96 |
{ |
... | ... |
@@ -0,0 +1,67 @@ |
1 |
+use Test::More 'no_plan'; |
|
2 |
+use strict; |
|
3 |
+use warnings; |
|
4 |
+ |
|
5 |
+use FindBin; |
|
6 |
+use utf8; |
|
7 |
+use lib "$FindBin::Bin/../mojo/lib"; |
|
8 |
+use lib "$FindBin::Bin/../lib"; |
|
9 |
+use lib "$FindBin::Bin/../extlib/lib/perl5"; |
|
10 |
+use File::Path 'rmtree'; |
|
11 |
+use Encode qw/encode decode/; |
|
12 |
+ |
|
13 |
+use Test::Mojo; |
|
14 |
+ |
|
15 |
+# Test DB |
|
16 |
+my $db_file = $ENV{GITPREP_DB_FILE} = "$FindBin::Bin/import_rep.db"; |
|
17 |
+ |
|
18 |
+# Test Repository home |
|
19 |
+my $rep_home = $ENV{GITPREP_REP_HOME} = "$FindBin::Bin/import_rep_user"; |
|
20 |
+ |
|
21 |
+use Gitprep; |
|
22 |
+ |
|
23 |
+# For perl 5.8 |
|
24 |
+{ |
|
25 |
+ no warnings 'redefine'; |
|
26 |
+ sub note { print STDERR "# $_[0]\n" unless $ENV{HARNESS_ACTIVE} } |
|
27 |
+} |
|
28 |
+ |
|
29 |
+note 'import_rep'; |
|
30 |
+{ |
|
31 |
+ unlink $db_file; |
|
32 |
+ rmtree $rep_home; |
|
33 |
+ |
|
34 |
+ my $app = Gitprep->new; |
|
35 |
+ my $t = Test::Mojo->new($app); |
|
36 |
+ $t->ua->max_redirects(3); |
|
37 |
+ |
|
38 |
+ # Create admin user |
|
39 |
+ $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}); |
|
40 |
+ $t->content_like(qr/Login Page/); |
|
41 |
+ |
|
42 |
+ # Login as admin |
|
43 |
+ $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'}); |
|
44 |
+ $t->content_like(qr/Admin/); |
|
45 |
+ |
|
46 |
+ # Create user |
|
47 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'}); |
|
48 |
+ $t->content_like(qr/Success.*created/); |
|
49 |
+ |
|
50 |
+ # Import repositories |
|
51 |
+ my $rep_dir = "$FindBin::Bin/../../gitprep_t_rep_home/kimoto"; |
|
52 |
+ chdir "$FindBin::Bin/../script" |
|
53 |
+ or die "Can't change directory: $!"; |
|
54 |
+ my @cmd = ('./import_rep', '-u', 'kimoto', $rep_dir); |
|
55 |
+ system(@cmd) == 0 |
|
56 |
+ or die "Command fail: @cmd"; |
|
57 |
+ |
|
58 |
+ # Branch |
|
59 |
+ ok(-f "$FindBin::Bin/import_rep_user/kimoto/gitprep_t.git/refs/heads/b1"); |
|
60 |
+ |
|
61 |
+ # Tag |
|
62 |
+ ok(-f "$FindBin::Bin/import_rep_user/kimoto/gitprep_t.git/refs/tags/t1"); |
|
63 |
+ |
|
64 |
+ # Description |
|
65 |
+ ok(-f "$FindBin::Bin/import_rep_user/kimoto/gitprep_t.git/description"); |
|
66 |
+} |
|
67 |
+ |