From eea1e69d0c66dbed5f75240bf48f01675c454a5d Mon Sep 17 00:00:00 2001 From: GeorgeClark Date: Mon, 28 Feb 2011 21:28:35 +0000 Subject: [PATCH] Item10307: Unit test for missing txt,v file save git-svn-id: http://svn.foswiki.org/trunk@10865 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- UnitTestContrib/test/unit/StoreTests.pm | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/UnitTestContrib/test/unit/StoreTests.pm b/UnitTestContrib/test/unit/StoreTests.pm index f2ff9fc4e5..9df800cae7 100644 --- a/UnitTestContrib/test/unit/StoreTests.pm +++ b/UnitTestContrib/test/unit/StoreTests.pm @@ -191,6 +191,58 @@ sub test_getRevisionInfo { $webObject->removeFromStore(); } +sub test_getRevisionInfoNoRcsFile { + my $this = shift; + + Foswiki::Func::createWeb( $web, '_default' ); + $this->assert( $this->{session}->webExists($web) ); + + my $ttext = <', "$Foswiki::cfg{DataDir}/$web/$topic.txt" ) + || die "Unable to open \n $! \n\n "; + print $fh $rawtext; + close $fh; + + # A file without history should be rev 0, not rev 1. + my $meta = Foswiki::Meta->load( $this->{session}, $web, $topic ); + #$this->assert_equals( 0, $meta->getLatestRev() ); + $this->assert_str_equals( $ttext, $meta->text() ); + + $meta->text( $ttext . "\nnewline" ); + # Save without force revision still should create a new rev due to missing history + $meta->save( forcenewrevision => 0 ); + + # Save of a file without an existing RCS file should not modify Rev 1, + # but should instead create the next revision, so rev 1 represents + # the original file before history started. + + my $readMeta = Foswiki::Meta->load( $this->{session}, $web, $topic ); + $this->assert_str_equals( $ttext . "\nnewline", $readMeta->text() ); + + $this->assert_equals( 2, $readMeta->getLatestRev() ); + my $info = $readMeta->getRevisionInfo(); + $this->assert_str_equals( $this->{session}->{user}, $info->{author} ); + $this->assert_num_equals( 2, $info->{version} ); + + # Make sure that rev 1 exists and has the original text pr-history. + my $oldMeta = Foswiki::Meta->load( $this->{session}, $web, $topic, '1'); + $this->assert_str_equals( $ttext, $oldMeta->text() ); + + my $webObject = Foswiki::Meta->new( $this->{session}, $web ); + $webObject->removeFromStore(); +} + sub test_moveTopic { my $this = shift;