#! /usr/bin/env perl # -*- perl -*-
my
%assets
;
$assets
{
'old.md'
} = {
title
=>
'Old'
,
content
=>
'valid'
,
};
$assets
{
'new.md'
} = {
title
=>
'New'
,
content
=>
'valid'
,
};
$assets
{
'template-added.md'
} = {
title
=>
'Template Added'
,
content
=>
'valid'
,
view
=>
'default.html'
};
$assets
{
'template-not-added.md'
} = {
title
=>
'Template Not Added'
,
content
=>
'valid'
,
view
=>
'new.html'
};
my
$site
= TestSite->new(
name
=>
'scm-mode'
,
assets
=> \
%assets
,
files
=> {
'_views/default.html'
=>
"[% asset.content %]"
,
'_views/new.html'
=>
"[% asset.content %]"
},
config
=> {
scm
=>
'git'
}
);
my
$repo_dir
= Cwd::abs_path(
'.'
);
ok (Git::Repository->run(
init
=> {
cwd
=>
$repo_dir
}));
my
$repo
= Git::Repository->new(
work_tree
=>
$repo_dir
);
ok
$repo
;
ok !
$repo
->run(
add
=>
'_config.yaml'
);
ok !
$repo
->run(
add
=>
'old.md'
);
ok !
$repo
->run(
add
=>
'template-added.md'
);
ok !
$repo
->run(
add
=>
'template-not-added.md'
);
ok !
$repo
->run(
add
=>
'_views/default.html'
);
open
my
$olderr
,
'>&STDERR'
or
die
"cannot dup stderr: $!"
;
close
STDERR;
ok(Qgoda::CLI->new([
'build'
])->dispatch);
open
STDERR,
'>&'
,
$olderr
;
my
$invalid
=
qr/^\[\% '' \%\]/
;
ok -e
'_site/old/index.html'
;
is ((read_file
'_site/old/index.html'
),
'<p>valid</p>'
);
ok ! -e
'_site/new/index.html'
;
ok -e
'_site/template-added/index.html'
;
is ((read_file
'_site/template-added/index.html'
),
'<p>valid</p>'
);
ok ! -e
'_site/template-not-added/index.html'
;
$site
->tearDown;
done_testing;