App-migrate
view release on metacpan or search on metacpan
t/load-err.t view on Meta::CPAN
use strict;
use POSIX qw(locale_h); BEGIN { setlocale(LC_MESSAGES,'en_US.UTF-8') } # avoid UTF-8 in $!
use Test::More;
use Test::Exception;
use Path::Tiny qw( path tempdir tempfile );
use App::migrate;
my $migrate = App::migrate->new;
my $file = tempfile('migrate.XXXXXX');
my $proj = tempdir('migrate.project.XXXXXX');
my $guard = bless {};
sub DESTROY { chdir q{/} }
chdir $proj or die "chdir($proj): $!";
throws_ok { $migrate->load('/dev/null') } qr/plain file/msi;
throws_ok { $migrate->load('/dev') } qr/plain file/msi;
$file->remove;
throws_ok { $migrate->load($file) } qr/^open\b/msi;
$file->touch;
lives_ok { $migrate->load($file) } 'empty file';
$file->spew_utf8(<<"MIGRATE");
# previous line is empty, next contain space symbols
\t
MIGRATE
lives_ok { $migrate->load($file) } 'empty lines and comments';
$file->spew_utf8(<<'MIGRATE');
MIGRATE
throws_ok { $migrate->load($file) } qr/bad token/msi, 'line with one space';
$file->spew_utf8(<<'MIGRATE');
# comment
MIGRATE
throws_ok { $migrate->load($file) } qr/bad token/msi, 'line begins with one space';
$file->spew_utf8(<<"MIGRATE");
\t# comment
MIGRATE
throws_ok { $migrate->load($file) } qr/bad token/msi, 'line begins with tab';
$file->spew_utf8(<<'MIGRATE');
true
MIGRATE
throws_ok { $migrate->load($file) } qr/data before operation/msi;
$file->spew_utf8(<<'MIGRATE');
VERSION "
MIGRATE
throws_ok { $migrate->load($file) } qr/bad operation param/msi;
$file->spew_utf8(<<'MIGRATE');
VERSION "1\.0"
MIGRATE
throws_ok { $migrate->load($file) } qr/bad operation param/msi;
( run in 0.797 second using v1.01-cache-2.11-cpan-ceb78f64989 )