more tests

redis
Sitaram Chamarty 2012-03-14 15:30:05 +05:30
parent 89cc3a303d
commit 141b2ce897
4 changed files with 136 additions and 102 deletions

View File

@ -77,6 +77,11 @@ sub _confargs {
sub confreset {
system("rm", "-rf", "conf");
mkdir("conf");
system("mv ~/repositories/gitolite-admin.git ~/repositories/.ga");
system("mv ~/repositories/testing.git ~/repositories/.te");
system("find ~/repositories -name '*.git' |xargs rm -rf");
system("mv ~/repositories/.ga ~/repositories/gitolite-admin.git");
system("mv ~/repositories/.te ~/repositories/testing.git ");
put "conf/gitolite.conf", '
repo gitolite-admin
RW+ = admin

79
t/include-subconf.t Executable file
View File

@ -0,0 +1,79 @@
#!/usr/bin/perl
use strict;
use warnings;
# this is hardcoded; change it if needed
use lib "src";
use Gitolite::Test;
try 'plan 37';
confreset; confadd '
include "i1.conf"
@i2 = b1
subconf "i2.conf"
include "i1.conf"
';
confadd 'i1.conf', '
@g1 = a1 a2
repo foo
RW = u1
include "j1.conf"
';
confadd 'i2.conf', '
@g2 = b1 b2
repo bar b1 b2 i1 i2 @i1 @i2 @g2
RW = u2
';
confadd 'j1.conf', '
@h2 = c1 c2
repo baz
RW = u3
';
try "ADMIN_PUSH set2; !/FATAL/" or die text();
try "
/i1.conf already included/
/i2.conf attempting to set access for \@i1, b2, bar, i1, locally modified \@g2/
!/attempting to set access.*i2/
/Initialized.*empty.*baz.git/
/Initialized.*empty.*foo.git/
/Initialized.*empty.*b1.git/
/Initialized.*empty.*i2.git/
!/Initialized.*empty.*b2.git/
!/Initialized.*empty.*i1.git/
!/Initialized.*empty.*bar.git/
";
confreset;confadd '
@g2 = i1 i2 i3
subconf "g2.conf"
';
confadd 'g2.conf', '
@g2 = g2 h2 i2
repo @g2
RW = u1
';
try "ADMIN_PUSH set3; !/FATAL/" or die text();
try "
/g2.conf attempting to set access for locally modified \@g2/
!/Initialized.*empty/
";
confreset;confadd '
@g2 = i1 i2 i3
subconf "g2.conf"
';
confadd 'g2.conf', '
subconf master
@g2 = g2 h2 i2
repo @g2
RW = u1
';
try "
ADMIN_PUSH set3; ok; /FATAL: subconf g2 attempting to run 'subconf'/
";

52
t/info.t Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/perl
use strict;
use warnings;
# this is hardcoded; change it if needed
use lib "src";
use Gitolite::Test;
try 'plan 35';
try "## info";
confreset;confadd '
repo t1
RW = u1
R = u2
repo t2
RW = u2
R = u1
repo t3
RW = u3
R = u4
';
try "ADMIN_PUSH info; !/FATAL/" or die text();
try "
/Initialized.*empty.*t1.git/
/Initialized.*empty.*t2.git/
/Initialized.*empty.*t3.git/
";
try "
glt info u1; ok; gsh
/R W *\tt1/
/R *\tt2/
!/t3/
/ R W *\ttesting/
glt info u2; ok; gsh
/R *\tt1/
/R W *\tt2/
!/t3/
/ R W *\ttesting/
glt info u3; ok; gsh
/R W *\tt3/
!/t1/
!/t2/
/ R W *\ttesting/
glt info u4; ok; gsh
/R *\tt3/
!/t1/
!/t2/
/ R W *\ttesting/
" or die;

View File

@ -1,102 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
use 5.10.0;
use Test;
BEGIN { plan tests =>
2
}
use lib "$ENV{PWD}/src";
use Gitolite::Test;
use Gitolite::Conf::Explode;
my @out;
my @out2;
warn "
<<< expect a couple of warnings about already included files >>>
";
# test 1 -- space normalisation
put "foo", "
foo line 1
foo=line 2
foo 3
";
@out = ();
explode("foo", 'master', \@out);
@out2 = (
'foo line 1',
'foo = line 2',
'foo 3',
);
ok(@out ~~ @out2);
# test 2 -- include/subconf processing
put "foo", "
foo line 1
\@fog=line 2
include \"bar.conf\"
foo line=5
subconf \"subs/baz.conf\"
include \"bar.conf\"
foo line=7
include \"bazup.conf\"
";
put "bar.conf", "
\@brg=line 1
bar line 3
";
mkdir("subs");
put "subs/baz.conf", "
\@bzg = line 1
include \"subs/baz2.conf\"
baz=line 3
";
put "subs/baz2.conf", "
baz2 line 1
baz2 line 2
include \"bazup.conf\"
baz2 line 4
";
put "bazup.conf", "
whatever...
";
@out = ();
explode("foo", 'master', \@out);
@out2 = (
'foo line 1',
'@fog = line 2',
'@brg = line 1',
'bar line 3',
'foo line = 5',
'subconf baz',
'@baz.bzg = line 1',
'baz2 line 1',
'baz2 line 2',
'whatever...',
'baz2 line 4',
'baz = line 3',
'subconf master',
'foo line = 7'
);
ok(@out ~~ @out2);