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