Skip to content

Commit

Permalink
Item9292: start to docco the status's in unit tests - some inconsiste…
Browse files Browse the repository at this point in the history
…ncies are worrying. I'm thinking about adding an IF(VERSION>1.1) die "fix this"; so that we can ignore it until we branch.

git-svn-id: http://svn.foswiki.org/trunk@8102 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Jul 10, 2010
1 parent c7525d6 commit 12cf562
Showing 1 changed file with 85 additions and 2 deletions.
87 changes: 85 additions & 2 deletions UnitTestContrib/test/unit/UIFnCompileTests.pm
Expand Up @@ -11,7 +11,7 @@ use Error qw( :try );

our $UI_FN;
our $SCRIPT_NAME;
our %expected_status = (
our %expected_status_main_webhome = (
search => 302,
save => 302,
login => 200,
Expand Down Expand Up @@ -156,7 +156,7 @@ sub verify_switchboard_function {
# preventing an admin from setting the security policy where possible.
# 666 is a default used in the UI_FN code above for 'unset'
$this->assert_num_equals(
$expected_status{$SCRIPT_NAME} || 666,
$expected_status_main_webhome{$SCRIPT_NAME} || 666,
$status,
"GOT Status : $status\nHEADER: $header\n\nSTDERR: "
. ( $stderr || '' ) . "\n"
Expand All @@ -174,6 +174,89 @@ sub verify_switchboard_function {
return;
}

sub verify_switchboard_function_nonExistantWeb {
my $this = shift;

#turn off ASSERTs so we can see what a normal run time will show
$ENV{FOSWIKI_ASSERTS} = 0;

my ( $status, $header, $result, $stdout, $stderr ) =
$this->call_UI_FN( 'Nosuchweb', $this->{test_topic} );

#TODO: I was expecting pretty much all scripts to return 302 redirect to oopsmissing
#shame we're still using 302 - when we're supposed to use 303/307 (http 1.1)
our %expected_status = (
compare => 302,
search => 302,
#TODO: save => 302, - no idea why it's returning OK-nostatus - especially as NoSuchTopic works
login => 200,
logon => 200,
);
$this->assert_num_equals(
$expected_status{$SCRIPT_NAME} || 666,
$status,
"GOT Status : $status\nHEADER: $header\n\nSTDERR: "
. ( $stderr || '' ) . "\n"
);
}

sub verify_switchboard_function_nonExistantTopic {
my $this = shift;

#turn off ASSERTs so we can see what a normal run time will show
$ENV{FOSWIKI_ASSERTS} = 0;

my ( $status, $header, $result, $stdout, $stderr ) =
$this->call_UI_FN( $this->{test_web}, 'NoSuchTopicBySven' );

#TODO: I was expecting pretty much all scripts to return 302 redirect to oopsmissing
#shame we're still using 302 - when we're supposed to use 303/307 (http 1.1)
our %expected_status = (
compare => 302,
search => 302,
save => 302,
login => 200,
logon => 200,
viewauth => 404,
view => 404,
);
$this->assert_num_equals(
$expected_status{$SCRIPT_NAME} || 666,
$status,
"GOT Status : $status\nHEADER: $header\n\nSTDERR: "
. ( $stderr || '' ) . "\n"
);
}

sub test_viewFile {
my $this = shift;

#turn off ASSERTs so we can see what a normal run time will show
$ENV{FOSWIKI_ASSERTS} = 0;

my ( $status, $header, $result, $stdout, $stderr ) =
$this->call_UI_FN( $this->{test_web}, 'NoSuchTopicBySven' );

#TODO: I was expecting pretty much all scripts to return 302 redirect to oopsmissing
#shame we're still using 302 - when we're supposed to use 303/307 (http 1.1)
our %expected_status = (
compare => 302,
search => 302,
save => 302,
login => 200,
logon => 200,
viewauth => 404,
view => 404,
);
$this->assert_num_equals(
$expected_status{$SCRIPT_NAME} || 666,
$status,
"GOT Status : $status\nHEADER: $header\n\nSTDERR: "
. ( $stderr || '' ) . "\n"
);
}
#TODO: add verify_switchboard_function_SecuredTopic_DENiedView

#TODO: craft specific tests for each script
#TODO: including timing expectations... (imo statistics takes a long time in this test)

Expand Down

0 comments on commit 12cf562

Please sign in to comment.