summaryrefslogtreecommitdiff
path: root/xt/cli/snapshot.t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-05-15 19:21:51 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-05-15 19:21:51 +0000
commite31f9059a9f3918f12c40d4d66f2db885d6f914a (patch)
treee87f850b34f4bafba1f735ed2162a0d7cba5a635 /xt/cli/snapshot.t
downloadCarton-tarball-e31f9059a9f3918f12c40d4d66f2db885d6f914a.tar.gz
Diffstat (limited to 'xt/cli/snapshot.t')
-rw-r--r--xt/cli/snapshot.t65
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;
+