From e4f920da810a263e8bae849b3c36c47caf4cdd40 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 24 Apr 2021 01:11:23 +0000 Subject: Rewrite test --- t/basic.t | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 't/basic.t') diff --git a/t/basic.t b/t/basic.t index f6e289f..0494ff0 100644 --- a/t/basic.t +++ b/t/basic.t @@ -5,17 +5,35 @@ use Apache::Test; use Apache::TestUtil; use Apache::TestRequest qw/GET_BODY/; -plan tests => 2; +plan tests => 1; -ok 1; +# (0) Prepare environment -open my $t, '<', 't/htdocs/test.html' or die; +# - Read contents of header and footer open my $h, '<', 't/htdocs/head.html' or die; open my $f, '<', 't/htdocs/foot.html' or die; -my $test = do { local $/; <$t> }; -my $head = do { local $/; <$h> }; -my $foot = do { local $/; <$f> }; -close $t; close $h; close $f; +chomp(my $head = do { local $/; <$h> }); +chomp(my $foot = do { local $/; <$f> }); +close $h; close $f; -my $body = GET_BODY '/test.html'; -ok $body, "$head$test$foot", 'Body of test.html includes header and footer'; +# - Open test file for writing +open my $t, '>', 't/htdocs/test.html' or die; +my $test; + +# (1) -less head + +$test = <Test +This is a test page. +END +seek($t, 0, 0); +print $t $test; + +ok GET_BODY('/test.html'), <-less head'; +Test +$head +This is a test page. +$foot +END + +close $t; -- cgit v1.2.3