add smart http test file
|
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/smart_http.db"; |
|
17 | ||
18 |
# Test Repository home |
|
19 |
my $rep_home = $ENV{GITPREP_REP_HOME} = "$FindBin::Bin/smart_http"; |
|
20 | ||
21 |
$ENV{GITPREP_NO_MYCONFIG} = 1; |
|
22 | ||
23 |
use Gitprep; |
|
24 | ||
25 |
# For perl 5.8 |
|
26 |
{ |
|
27 |
no warnings 'redefine'; |
|
28 |
sub note { print STDERR "# $_[0]\n" unless $ENV{HARNESS_ACTIVE} } |
|
29 |
} |
|
30 | ||
31 |
note 'Smart HTTP'; |
|
32 |
{ |
|
33 |
unlink $db_file; |
|
add dump http info/refs test
|
34 |
rmtree $rep_home; |
add smart http test file
|
35 | |
36 |
my $app = Gitprep->new; |
|
37 |
my $t = Test::Mojo->new($app); |
|
38 |
$t->ua->max_redirects(3); |
|
39 | ||
40 |
# Create admin user |
|
41 |
$t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}); |
|
42 |
$t->content_like(qr/Login page/); |
|
43 | ||
44 |
# Login success |
|
45 |
$t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'}); |
|
46 |
$t->content_like(qr/Admin/); |
|
47 |
|
|
48 |
# Create user |
|
49 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'}); |
|
50 |
$t->content_like(qr/Success.*created/); |
|
add dump http info/refs test
|
51 | |
52 |
# Login as kimoto |
|
53 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'}); |
|
54 |
$t->get_ok('/')->content_like(qr/kimoto/); |
|
55 | ||
56 |
# Create repository |
|
57 |
$t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello', readme => 1}); |
|
58 |
$t->content_like(qr/README/); |
|
59 |
|
|
60 |
# info/refs |
|
61 |
$t->get_ok("/kimoto/t1.git/info/refs"); |
|
62 |
$t->status_is(200); |
|
63 |
$t->content_type_is('text/plain; charset=UTF-8'); |
|
64 | ||
65 |
=pod |
|
66 |
# Loose object |
|
67 |
$t->get_ok("/kimoto/t1.git/objects/20/42336f878dd054083193909140d1d10c16e775"); |
|
68 |
$t->status_is(200); |
|
69 |
$t->content_type_is('application/x-git-loose-object'); |
|
70 |
=cut |
|
71 | ||
add smart http test file
|
72 |
|
73 |
|
|
74 |
} |