Skip to content

Commit

Permalink
Item8640: Hopefully last of the major changes to the Package.pm insta…
Browse files Browse the repository at this point in the history
…ller. But still a lot to do:

 - Probably, nah - really still ugly - first change to recursive installation of packages
 - Needs more error handling.  
 - CPAN deps need to be handled in the shell installer.
 - Reminder to enable plugins got dropped.
 - Still needs code to archive the backups.
 - Unit tests still run here.



git-svn-id: http://svn.foswiki.org/trunk@6987 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Mar 29, 2010
1 parent 6cec8a1 commit 710b4d7
Show file tree
Hide file tree
Showing 4 changed files with 423 additions and 440 deletions.
72 changes: 57 additions & 15 deletions UnitTestContrib/test/unit/ConfigureTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,13 @@ sub test_Package_makeBackup {

use Foswiki::Configure::Package;
my $pkg =
new Foswiki::Configure::Package( $root, "$extension", 'Plugin',
new Foswiki::Configure::Package( $root, "$extension",
$this->{session} );

( $result, $err ) = $pkg->loadInstaller($tempdir);
$this->assert_str_equals( '', $err );

( $result, $err ) = $pkg->install($tempdir);
( $result, $err ) = $pkg->install( { DIR => $tempdir, EXPANDED => 1 });

my $msg = $pkg->createBackup();
$this->assert_matches( qr/Backup saved into/, $msg );
Expand Down Expand Up @@ -1059,8 +1059,7 @@ DONE
#
#
my $pkg =
new Foswiki::Configure::Package( $root, 'MyPlugin', 'Plugin',
$this->{session} );
new Foswiki::Configure::Package( $root, 'MyPlugin', $this->{session} );
( $result, $err ) = $pkg->loadInstaller($tempdir);
$pkg->uninstall();
$pkg->finish();
Expand All @@ -1072,10 +1071,9 @@ DONE

_makePackage( $tempdir, $extension );
$pkg =
new Foswiki::Configure::Package( $root, 'MyPlugin', 'Plugin',
$this->{session} );
new Foswiki::Configure::Package( $root, 'MyPlugin', $this->{session} );
( $result, $err ) = $pkg->loadInstaller($tempdir);
( $result, $err ) = $pkg->install($tempdir);
( $result, $err ) = $pkg->install( { DIR => $tempdir, EXPANDED => 1} );
$this->assert_str_equals( '', $err );

my $expresult = "Installed: data/Sandbox/TestTopic1.txt
Expand Down Expand Up @@ -1112,14 +1110,13 @@ Installed: MyPlugin_installer
_makePackage( $tempdir, $extension );

my $pkg2 =
new Foswiki::Configure::Package( $root, 'MyPlugin', 'Plugin',
$this->{session} );
new Foswiki::Configure::Package( $root, 'MyPlugin', $this->{session} );
( $result, $err ) = $pkg2->loadInstaller($tempdir);

print "ERRORS: $err\n" if ($err);

$result = '';
( $result, $err ) = $pkg2->install($tempdir);
( $result, $err ) = $pkg2->install({ DIR => $tempdir, EXPANDED => 1 } );

$expresult = "Installed: data/Sandbox/TestTopic1.txt
Checked in: data/Sandbox/TestTopic43.txt as $this->{sandbox_web}.TestTopic43
Expand All @@ -1139,6 +1136,13 @@ Installed: MyPlugin_installer
); # + 3 rcs files after checkin
$this->assert_str_equals( '', $err, "Error $err reported" );

#
# Verify the pre/post install exits
#

$err = $pkg2->loadExits();
$this->assert_str_equals( '', $err, "Load exits failed with $err ");

$this->assert_str_equals( 'Pre-install entered', $pkg2->preinstall() );
$this->assert_str_equals( "Removed $tempdir/obsolete.pl",
$pkg2->postinstall() );
Expand Down Expand Up @@ -1213,6 +1217,39 @@ Installed: MyPlugin_installer

#}

#
# Determine that installer can download the package from Foswiki.org if not available locally
#
sub test_Package_loadInstaller {
my $this = shift;
my $root = $this->{rootdir};

my $tempdir = $this->{tempdir} . '/test_Package_loadInstaller';
rmtree($tempdir); # Clean up old files if left behind
mkpath($tempdir);

my $repository = {
name => 'Foswiki',
data => 'http://foswiki.org/Extensions/',
pub => 'http://foswiki.org/pub/Extensions/'
};
my $pkg =
new Foswiki::Configure::Package( $root, 'EmptyPlugin', $this->{session} );
$pkg->repository($repository);
my ( $result, $err ) = $pkg->loadInstaller($tempdir );

chomp $result;
$this->assert_matches (qr/Unable to find EmptyPlugin locally in (.*) ...fetching from Foswiki ... succeeded/, $result, "Unexpected $result from loadInstaller");
$this->assert_str_equals ('', $err, "Error from loadInstaller $err");

my @files = $pkg->files();
$this->assert_num_equals(3, scalar @files, "Unexpected number of files in EmptyPlugin manifest");

$pkg->finish();
undef $pkg;
}


sub test_Load_expandValue {
my $this = shift;

Expand All @@ -1222,17 +1259,22 @@ sub test_Load_expandValue {
$this->assert_str_equals( "$Foswiki::cfg{WorkingDir}/test", $logv );
}

sub _test_Package_fetchFile {
my $this = shift;
sub test_Package_fetchFile {
my $this = shift;
my $root = $this->{_rootdir};

my $repository = {
my $repository = {
name => 'Foswiki',
data => 'http://foswiki.org/Extensions/',
pub => 'http://foswiki.org/pub/Extensions/'
};
my ($resp, $file) = Foswiki::Configure::Package::_fetchFile( $repository, 'EmptyPlugin', '_installer' );

my $pkg =
new Foswiki::Configure::Package( $root, 'EmptyPlugin');
$pkg->repository($repository);

print "$resp, for $file \n";
my ($resp, $file) = $pkg->_fetchFile( '_installer' );
$this->assert_str_equals('', $resp);
}

1;
Loading

0 comments on commit 710b4d7

Please sign in to comment.