Changeset 9846


Ignore:
Timestamp:
11/04/10 00:29:59 (19 months ago)
Author:
GeorgeClark
Message:

Item9083: Unit test to verify no newlines dropped
during round-trip read and save topic with Func

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x01/UnitTestContrib/test/unit/FuncTests.pm

    r9596 r9846  
    380380      Foswiki::Func::saveTopicText( $this->{test_web}, $topic, 'Beam', 1 ); 
    381381    $this->assert( !$oopsURL, $oopsURL ); 
     382} 
     383 
     384# Verify that a round trip doesn't remove or add any newlines between the topic and 
     385# the metadata in the raw text. 
     386sub test_saveTopicRoundTrip { 
     387    my $this  = shift; 
     388    my $topic = 'SaveTopicText2'; 
     389    my $origtext = <<NONNY; 
     390'Tis some text 
     391and a trailing newline 
     392 
     393 
     394 
     395%META:FILEATTACHMENT{name="IMG_0608.JPG" attr="" autoattached="1" comment="A Comment" date="1162233146" size="762004" user="Main.AUser" version="1"}% 
     396NONNY 
     397    Foswiki::Func::saveTopicText( $this->{test_web}, $topic, $origtext ); 
     398    my $text1 = Foswiki::Func::readTopicText( $this->{test_web}, $topic ); 
     399 
     400    my ( $meta, $text ) = Foswiki::Func::readTopic( $this->{test_web}, $topic ); 
     401    Foswiki::Func::saveTopic( $this->{test_web}, $topic, $meta, $text, 
     402      { comment => 'atp save' } ); 
     403    my $text2 = Foswiki::Func::readTopicText( $this->{test_web}, $topic ); 
     404 
     405    my $matchText = '%META:TOPICINFO{author="BaseUserMapping_666" comment="save topic" date=".*?" format="1.1" reprev="1" version="1"}%' . "\n" . $origtext; 
     406    $this->assert_matches( qr/$matchText/, $text2 ); 
     407 
    382408} 
    383409 
Note: See TracChangeset for help on using the changeset viewer.