Select Git revision

Andreas Romeyke authored
02-init.t 1.55 KiB
use v5.36;
use Test::Cmd;
use Test::More tests =>7;
use Path::Tiny;
my $perl = $^X;
my $testapp = Test::Cmd->new(
prog => path(__FILE__)->parent->parent->child('bin')->child('ta-tool.pl'),
workdir => '',
subdir => 'bin',
#verbose => 1,
interpreter => "$perl -I lib/ ",
);
local $ENV{'HOME'} = $testapp->workpath();
my $config_dir = path($testapp->workpath())->child('.config');
$config_dir->mkpath();
my $config_file = $config_dir->child('ta-tool.rc');
my $cache_dir = path($testapp->workpath())->child('.cache');
$cache_dir->mkpath();
my $cache_file = $cache_dir->child('ta-tool.cache');
# tests
ok($testapp, "init 'ta-tool'");
$testapp->run(
stdin => <<_EOF_,
lza
199fc76b9d086d8937976634e93413bcd005d941
199fc76b9d086d8937976634e93413bcd005d941
_EOF_
args => 'init -v -e sdvlzaamtestfotothek01.slub-dresden.de -l /tmp',
);
like($testapp->stdout, qr/User:.*store config in /s, 'ta-tool init, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool init, stderr');
unlike($testapp->stderr, qr/Error/, 'ta-tool init, stderr indicates no error');
is($? >> 8, 0, 'ta-tool init, exit status');
my $config = $config_file->slurp_utf8();
is($config, <<_EXP_, "ta-tool init, config file as expected");
---
elasticsearchhost: sdvlzaamtestfotothek01.slub-dresden.de
elasticsearchport: 9200
httponly: ~
logdir: /tmp
password: 839852bed005a7f1237578a6ac1197c142f7d0dd58bb248446dc7849d4bf770902e7f980ad83d39008ad638bc41e2345
user: lza
_EXP_
my $cache = $cache_file->slurp_utf8();
is($cache, <<_EXP_, "ta-tool init, cache file as expected");
--- {}
_EXP_
1;