diff options
Diffstat (limited to 'tests/server/admin-t')
| -rwxr-xr-x | tests/server/admin-t | 22 | 
1 files changed, 19 insertions, 3 deletions
| diff --git a/tests/server/admin-t b/tests/server/admin-t index 5bde104..6846609 100755 --- a/tests/server/admin-t +++ b/tests/server/admin-t @@ -3,12 +3,13 @@  # Tests for the wallet-admin dispatch code.  #  # Written by Russ Allbery <rra@stanford.edu> -# Copyright 2008, 2009, 2010 Board of Trustees, Leland Stanford Jr. University +# Copyright 2008, 2009, 2010, 2011 +#     The Board of Trustees of the Leland Stanford Junior University  #  # See LICENSE for licensing terms.  use strict; -use Test::More tests => 36; +use Test::More tests => 42;  # Create a dummy class for Wallet::Admin that prints what method was called  # with its arguments and returns data for testing. @@ -57,6 +58,12 @@ sub register_verifier {      return 1;  } +sub upgrade { +    print "upgrade\n"; +    return if $error; +    return 1; +} +  # Back to the main package and the actual test suite.  Lie about whether the  # Wallet::Admin package has already been loaded.  package main; @@ -86,7 +93,8 @@ is ($out, "new\n", ' and nothing ran');  # Check too few and too many arguments for every command.  my %commands = (destroy    => [0,  0],                  initialize => [1,  1], -                register   => [3,  3]); +                register   => [3,  3], +                upgrade    => [0,  0]);  for my $command (sort keys %commands) {      my ($min, $max) = @{ $commands{$command} };      if ($min > 0) { @@ -150,6 +158,11 @@ is ($err, '', 'Register succeeds for verifier');  is ($out, "new\nregister_verifier foo Foo::Verifier\n",      ' and returns the right outout'); +# Test upgrade. +($out, $err) = run_admin ('upgrade'); +is ($err, '', 'Upgrade succeeds'); +is ($out, "new\nupgrade\n", ' and runs the right code'); +  # Test error handling.  $Wallet::Admin::error = 1;  ($out, $err) = run_admin ('destroy'); @@ -169,3 +182,6 @@ is ($out, "new\nregister_object foo Foo::Object\n",  is ($err, "some error\n", 'Error handling succeeds for register verifier');  is ($out, "new\nregister_verifier foo Foo::Verifier\n",      ' and calls the right methods'); +($out, $err) = run_admin ('upgrade'); +is ($err, "some error\n", 'Error handling succeeds for initialize'); +is ($out, "new\nupgrade\n", ' and calls the right methods'); | 
