Skip to content

Commit 12aaffb

Browse files
committed
Add tests for clean command
1 parent 9574ff6 commit 12aaffb

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

t/command-clean.t

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#! /usr/bin/env perl6
2+
3+
use v6.c;
4+
5+
use App::Cpan6::Commands::Clean;
6+
use App::Cpan6::Commands::New;
7+
use App::Cpan6::Meta;
8+
use File::Temp;
9+
use Test;
10+
11+
multi sub MAIN { 0 }
12+
13+
# Disable git
14+
%*ENV<CPAN6_EXTERNAL_GIT> = False;
15+
16+
my $root = tempdir;
17+
18+
chdir $root;
19+
20+
plan 4;
21+
22+
ok MAIN(
23+
"new",
24+
name => "Local::Test::Clean",
25+
author => "Patrick Spek",
26+
email => "p.spek@tyil.work",
27+
perl => "c",
28+
description => "Nondescript",
29+
license => "GPL-3.0",
30+
no-user-config => True,
31+
), "cpan6 new Local::Test::Clean";
32+
33+
# Create a non-clean META6.json
34+
my %meta = get-meta;
35+
%meta<provides><Local::Test::Clean::Orphan> = "lib/non-existant.pm6";
36+
37+
subtest "cpan6 clean", {
38+
plan 3;
39+
40+
# Setup
41+
mkdir "resources";
42+
spurt "resources/alpha", "";
43+
put-meta(:%meta);
44+
45+
# Test
46+
ok MAIN("clean", :force);
47+
nok "resources/alpha".IO.e;
48+
nok get-meta()<provides><Local::Test::Clean::Orphan>:exists;
49+
}
50+
51+
subtest "cpan6 --no-files clean", {
52+
plan 3;
53+
54+
# Setup
55+
mkdir "resources";
56+
spurt "resources/beta", "";
57+
put-meta(:%meta);
58+
59+
# Test
60+
ok MAIN("clean", :force, :no-files);
61+
ok "resources/beta".IO.e;
62+
nok get-meta()<provides><Local::Test::Clean::Orphan>:exists;
63+
}
64+
65+
subtest "cpan6 --no-meta clean", {
66+
plan 3;
67+
68+
# Setup
69+
mkdir "resources";
70+
spurt "resources/gamma", "";
71+
put-meta(:%meta);
72+
73+
# Test
74+
ok MAIN("clean", :force, :no-meta);
75+
nok "resources/gamma".IO.e;
76+
ok get-meta()<provides><Local::Test::Clean::Orphan>:exists;
77+
}
78+
79+
# vim: ft=perl6 noet

0 commit comments

Comments
 (0)