Annotation of todotxt/Text-Todo/t/dudelicious.t, Revision 1.5
1.3 andrew 1: #!perl
2: use Test::More; # tests => 3;
3:
4: use strict;
5: use warnings;
6:
7: use File::Temp qw/ tempdir /;
8: use File::Copy qw/ cp /;
9: use File::Spec;
1.1 andrew 10:
11: BEGIN {
1.3 andrew 12: eval "use Test::Mojo";
13: plan skip_all => "Test::Mojo required for testing dudelicious" if $@;
14:
15: }
1.1 andrew 16:
1.3 andrew 17: my $todo_dir = tempdir( 'todo-XXXXXXXXX', CLEANUP => 1, TMPDIR => 1 );
18: $ENV{DUDELICIOUS_HOME} = $todo_dir;
19:
20: foreach my $file qw( todo1.txt todo.list.txt dudelicious.conf ) {
21: cp( File::Spec->catfile( 't', $file ),
22: File::Spec->catfile( $todo_dir, $file ),
23: ) || die "Couldn't cp [$todo_dir]/[$file]: $!";
1.1 andrew 24: }
25:
1.3 andrew 26: require File::Spec->catfile( 'bin', 'dudelicious.pl' );
27: Dudelicious->import;
28: Dudelicious->app->log->level('error');
1.1 andrew 29:
30: my $t = Test::Mojo->new;
31:
1.5 ! andrew 32: my @exts = ( q{}, '.html', '.txt', '.json' );
1.3 andrew 33:
1.4 andrew 34: foreach my $p (
35: '/',
1.5 ! andrew 36: ( map { '/l/todo1' . $_ } @exts ),
! 37: ( map { '/l/todo1/e/1' . $_ } @exts ),
! 38: ( map { '/l/todo1/e/4' . $_ } @exts ),
! 39: ( map { '/l/todo1/t' . $_ } @exts ),
! 40: ( map { '/l/todo1/t/project' . $_ } @exts ),
! 41: ( map { '/l/todo1/t/context' . $_ } @exts ),
! 42: )
! 43: {
! 44: my ( $volume, $directories, $file ) = File::Spec->splitpath($p);
! 45:
1.4 andrew 46: $file ||= 'index.html';
1.5 ! andrew 47: $file .= '.html' if $file !~ /\.[^.]+$/xms;
1.4 andrew 48:
1.5 ! andrew 49: my $f = File::Spec->catfile( 't', 'dudelicious', $volume, $directories,
! 50: $file );
1.4 andrew 51:
1.5 ! andrew 52: SKIP: {
! 53: skip "$f does not exist", 3 if !-e $f;
1.4 andrew 54:
1.5 ! andrew 55: diag("Getting [$f] from [$p]");
! 56: open my $fh, '<', $f or die $f . ': ' . $!;
! 57: $t->get_ok($p)->status_is(200)->content_is(
! 58: do { local $/; <$fh> }
! 59: );
! 60: close $fh;
1.4 andrew 61: }
1.3 andrew 62: }
63:
1.4 andrew 64: done_testing();
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>