diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-15 19:21:51 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-15 19:21:51 +0000 |
commit | e31f9059a9f3918f12c40d4d66f2db885d6f914a (patch) | |
tree | e87f850b34f4bafba1f735ed2162a0d7cba5a635 /xt/cli/snapshot.t | |
download | Carton-tarball-e31f9059a9f3918f12c40d4d66f2db885d6f914a.tar.gz |
Carton-v1.0.21HEADCarton-v1.0.21master
Diffstat (limited to 'xt/cli/snapshot.t')
-rw-r--r-- | xt/cli/snapshot.t | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/xt/cli/snapshot.t b/xt/cli/snapshot.t new file mode 100644 index 0000000..b036af7 --- /dev/null +++ b/xt/cli/snapshot.t @@ -0,0 +1,65 @@ +use strict; +use Test::More; +use xt::CLI; + +subtest 'snapshot file has canonical representation' => sub { + my $app = cli(); + $app->write_cpanfile(<<EOF); +requires 'Try::Tiny', '== 0.11'; +requires 'Getopt::Long', '2.41'; +EOF + + $app->run("install"); + + my $content = $app->dir->child('cpanfile.snapshot')->slurp; + for (1..3) { + $app->dir->child('cpanfile.snapshot')->remove; + $app->run("install"); + is $content, $app->dir->child('cpanfile.snapshot')->slurp; + } +}; + +subtest 'Bad snapshot version' => sub { + my $app = cli(); + $app->write_cpanfile(''); + $app->write_file('cpanfile.snapshot', <<EOF); +# carton snapshot format: version 111 +EOF + + $app->run("install"); + like $app->stderr, qr/Could not parse/; +}; + +subtest 'Bad snapshot file' => sub { + my $app = cli(); + $app->write_cpanfile(''); + $app->write_file('cpanfile.snapshot', <<EOF); +# carton snapshot format: version 1.0 +DISTRIBUTIONS + Foo-Bar-1 + unknown: foo +EOF + + $app->run("install"); + like $app->stderr, qr/Could not parse/; +}; + +subtest 'snapshot file support separate CRLF' => sub { + my $app = cli(); + $app->write_cpanfile(<<EOF); +requires 'Try::Tiny', '== 0.11'; +requires 'Getopt::Long', '2.41'; +EOF + + $app->run("install"); + + my $content = $app->dir->child('cpanfile.snapshot')->slurp; + $content =~ s/\n/\r\n/g; + $app->write_file('cpanfile.snapshot', $content); + + $app->run("install"); + ok !$app->stderr; +}; + +done_testing; + |