diff --git a/t/02-init.t b/t/02-init.t index c958aa8520cf7b6855a89e2e5adb11ae03aaee5d..a5b0a08183577f00869981d9d1a30c1325445df3 100644 --- a/t/02-init.t +++ b/t/02-init.t @@ -1,6 +1,6 @@ use v5.36; use Test::Cmd; -use Test::More tests =>19; +use Test::More tests =>6; use Path::Tiny; my $perl = $^X; my $testapp = Test::Cmd->new( @@ -25,34 +25,37 @@ is(SLUB::LZA::TA::Crypt::encrypt("199fc76b9d086d8937976634e93413bcd005d941"), "8 is(SLUB::LZA::TA::Crypt::decrypt("839852bed005a7f1237578a6ac1197c142f7d0dd58bb248446dc7849d4bf770902e7f980ad83d39008ad638bc41e2345"), "199fc76b9d086d8937976634e93413bcd005d941", "ta-tool, init, check encryption"); ok($testapp, "init 'ta-tool'"); -note "help check"; -foreach my $param ("help init", "init -h", "init --help") { - $testapp->run(args => $param); - #say "STDOUT:",$testapp->stdout; - #say "STDERR:",$testapp->stderr; - like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); - like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); - is($? >> 8, 0, "ta-tool $param, exit status"); -} +subtest 'help check' => sub { + plan tests => 9; + foreach my $param ("help init", "init -h", "init --help") { + $testapp->run(args => $param); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); + like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); + is($? >> 8, 0, "ta-tool $param, exit status"); + } +}; -note "init check"; -$testapp->run( - stdin => <<_EOF_, +subtest 'init check' => sub { + plan tests => 6; + $testapp->run( + stdin => <<_EOF_, lza 199fc76b9d086d8937976634e93413bcd005d941 199fc76b9d086d8937976634e93413bcd005d941 _EOF_ - args => 'init -D -v -e sdvlzaamtestfotothek01.slub-dresden.de', - #args => 'init -e sdvlzaamtestfotothek01.slub-dresden.de -l /tmp', -); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -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"); + args => 'init -D -v -e sdvlzaamtestfotothek01.slub-dresden.de', + #args => 'init -e sdvlzaamtestfotothek01.slub-dresden.de -l /tmp', + ); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + 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"); --- elasticsearch_host: sdvlzaamtestfotothek01.slub-dresden.de elasticsearch_port: 9200 @@ -60,9 +63,10 @@ http_only: ~ password: 839852bed005a7f1237578a6ac1197c142f7d0dd58bb248446dc7849d4bf770902e7f980ad83d39008ad638bc41e2345 user: lza _EXP_ -my $cache = $cache_file->slurp_utf8(); -is($cache, <<_EXP_, "ta-tool init, cache file as expected"); + my $cache = $cache_file->slurp_utf8(); + is($cache, <<_EXP_, "ta-tool init, cache file as expected"); --- {} _EXP_ +}; 1; diff --git a/t/03-count.t b/t/03-count.t index ae625c16f9a3eca248bb898be36021aedc0ef02c..99344967b1f2569989fec02f613b24283fe1b6a7 100644 --- a/t/03-count.t +++ b/t/03-count.t @@ -1,6 +1,6 @@ use v5.36; use Test::Cmd; -use Test::More tests =>30; +use Test::More tests =>6; use Path::Tiny; my $perl = $^X; my $testapp = Test::Cmd->new( @@ -27,82 +27,81 @@ password: 839852bed005a7f1237578a6ac1197c142f7d0dd58bb248446dc7849d4bf770902e7f9 user: lza _CFG_ # tests -note "help check"; -foreach my $param ("help count", "count -h", "count --help") { - $testapp->run(args => $param); - #say "STDOUT:",$testapp->stdout; - #say "STDERR:",$testapp->stderr; - like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); - like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); - is($? >> 8, 0, "ta-tool $param, exit status"); -} - -note "check cli params"; -$testapp->run(args =>'count --lzaid SLUB:LZA:goobi:1 --debug'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr//, 'ta-tool count by lzaid, wrong format, stdout'); -like($testapp->stderr, qr/Error: --[a-z].* expects.*Usage/s, 'ta-tool count by lzaid, wrong format, stderr'); -isnt($? >> 8, 0, 'ta-tool count by lzaid, wrong format, exit status'); -#note "elastic count non-existing lza id"; -#$testapp->run(args =>'count --lzaid SLUB:LZA:goobi:1 --debug'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -#like($testapp->stdout, qr/must=/, 'ta-tool count by lzaid, no match, stdout'); -#like($testapp->stderr, qr/^$/, 'ta-tool count by lzaid, no match, stderr'); -#is($? >> 8, 0, 'ta-tool count by lzaid, no match, exit status'); +subtest 'help check' => sub { + plan tests => 9; + foreach my $param ("help count", "count -h", "count --help") { + $testapp->run(args => $param); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); + like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); + is($? >> 8, 0, "ta-tool $param, exit status"); + } +}; +subtest 'check cli params' => sub { + plan tests => 3; + $testapp->run(args => 'count --lzaid SLUB:LZA:goobi:1 --debug'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr//, 'ta-tool count by lzaid, wrong format, stdout'); + like($testapp->stderr, qr/Error: --[a-z].* expects.*Usage/s, 'ta-tool count by lzaid, wrong format, stderr'); + isnt($? >> 8, 0, 'ta-tool count by lzaid, wrong format, exit status'); +}; -#$testapp->run(args =>'count --lzaid SLUB:LZA:goobi:1'); -#like($testapp->stdout, qr/must=/, 'ta-tool count by lzaid, no match, stdout'); -#like($testapp->stderr, qr/^$/, 'ta-tool count by lzaid, no match, stderr'); -#is($? >> 8, 0, 'ta-tool count by lzaid, no match, exit status'); - -note "elastic count existing lza id"; -$testapp->run(args =>'count --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --debug'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^1$/s, 'ta-tool count by lzaid, existing, stdout'); -like($testapp->stderr, qr/\A\@must=.*/, 'ta-tool count by lzaid, existing, stderr'); -is($? >> 8, 0, 'ta-tool count by lzaid, no match, exit status'); -$testapp->run(args =>'count --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^1$/s, 'ta-tool count by lzaid, existing, stdout'); -like($testapp->stderr, qr/^$/, 'ta-tool count by lzaid, existing, stderr'); -is($? >> 8, 0, 'ta-tool count by lzaid, existing, exit status'); +subtest 'elastic count existing lza id' => sub { + plan tests => 6; + $testapp->run(args => 'count --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --debug'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^1$/s, 'ta-tool count by lzaid, existing, stdout'); + like($testapp->stderr, qr/\A\@must=.*/, 'ta-tool count by lzaid, existing, stderr'); + is($? >> 8, 0, 'ta-tool count by lzaid, no match, exit status'); + $testapp->run(args => 'count --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^1$/s, 'ta-tool count by lzaid, existing, stdout'); + like($testapp->stderr, qr/^$/, 'ta-tool count by lzaid, existing, stderr'); + is($? >> 8, 0, 'ta-tool count by lzaid, existing, exit status'); +}; -note "elastic count existing dc entry"; -$testapp->run(args =>'count --descriptive "Retrodigitalisierte Fotosn"');#SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^30$/, 'ta-tool count by dc, existing, stdout'); -like($testapp->stderr, qr/^$/, 'ta-tool count by dc, existing, stderr'); -is($? >> 8, 0, 'ta-tool count by lzaid, existing, exit status'); +subtest 'elastic count existing dc entry' => sub { + plan tests => 3; + $testapp->run(args => 'count --descriptive "Retrodigitalisierte Fotosn"'); #SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^30$/, 'ta-tool count by dc, existing, stdout'); + like($testapp->stderr, qr/^$/, 'ta-tool count by dc, existing, stderr'); + is($? >> 8, 0, 'ta-tool count by lzaid, existing, exit status'); +}; -note "elastic count dates"; -$testapp->run(args =>'count --creationdate 2023-09-05'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^2$/, 'ta-tool count date, existing, stdout'); -like($testapp->stderr, qr/^$/, 'ta-tool count date, existing, stderr'); -is($? >> 8, 0, 'ta-tool count date, existing, exit status'); +subtest 'elastic count dates' => sub { + plan tests => 6; + $testapp->run(args => 'count --creationdate 2023-09-05'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^2$/, 'ta-tool count date, existing, stdout'); + like($testapp->stderr, qr/^$/, 'ta-tool count date, existing, stderr'); + is($? >> 8, 0, 'ta-tool count date, existing, exit status'); -$testapp->run(args =>'count --creationdate-from 2023-09-05 --creationdate-to 2023-12-22'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^25$/, 'ta-tool count dates, existing, stdout'); -like($testapp->stderr, qr/^$/, 'ta-tool count dates, existing, stderr'); -is($? >> 8, 0, 'ta-tool count dates, existing, exit status'); + $testapp->run(args => 'count --creationdate-from 2023-09-05 --creationdate-to 2023-12-22'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^25$/, 'ta-tool count dates, existing, stdout'); + like($testapp->stderr, qr/^$/, 'ta-tool count dates, existing, stderr'); + is($? >> 8, 0, 'ta-tool count dates, existing, exit status'); +}; -note "overrides"; -$testapp->run(args =>'count --elasticsearch-host localhost --creationdate-from 2023-09-05 --creationdate-to 2023-12-22'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^$/, 'ta-tool count dates, existing, override, stdout'); -like($testapp->stderr, qr/^Hint: override local config with/, 'ta-tool count dates, existing, override, stderr'); -is($? >> 8, 111, 'ta-tool count dates, existing, override, exit status'); +subtest 'overrides' => sub { + plan tests => 3; + $testapp->run(args => 'count --elasticsearch-host localhost --creationdate-from 2023-09-05 --creationdate-to 2023-12-22'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^$/, 'ta-tool count dates, existing, override, stdout'); + like($testapp->stderr, qr/^Hint: override local config with/, 'ta-tool count dates, existing, override, stderr'); + is($? >> 8, 111, 'ta-tool count dates, existing, override, exit status'); +}; 1; diff --git a/t/03-info.t b/t/03-info.t index 08ebf16f6b1a74e743723a3ab92de41076c4ff8c..544495c45bf5e01574ee3c55771e6e4a31e513f4 100644 --- a/t/03-info.t +++ b/t/03-info.t @@ -1,6 +1,6 @@ use v5.36; use Test::Cmd; -use Test::More tests =>15; +use Test::More tests =>3; use Path::Tiny; my $perl = $^X; my $testapp = Test::Cmd->new( @@ -27,29 +27,35 @@ password: 839852bed005a7f1237578a6ac1197c142f7d0dd58bb248446dc7849d4bf770902e7f9 user: lza _CFG_ # tests -note "help check"; -foreach my $param ("help info", "info -h", "info --help") { - $testapp->run(args => $param); - #say "STDOUT:",$testapp->stdout; - #say "STDERR:",$testapp->stderr; - like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); - like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); - is($? >> 8, 0, "ta-tool $param, exit status"); -} +subtest 'help check' => sub { + plan tests => 9; + foreach my $param ("help info", "info -h", "info --help") { + $testapp->run(args => $param); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); + like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); + is($? >> 8, 0, "ta-tool $param, exit status"); + } +}; -note "elastic search version"; -$testapp->run(args =>'info --target-version'); -like($testapp->stdout, qr/^6\.\d\.\d{1,2}$/, 'ta-tool elasticsearch version, stdout'); -like($testapp->stderr, qr/^$/, 'ta-tool elasticsearch version, stderr'); -is($? >> 8, 0, 'ta-tool elasticsearch version, exit status'); +subtest 'elastic search version' => sub { + plan tests => 3; -note "overrides"; -$testapp->run(args =>'info --elasticsearch-host localhost --target-version'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^$/, 'ta-tool elasticsearch version, override, stdout'); -like($testapp->stderr, qr/^Hint: override local config/, 'ta-tool elasticsearch version, override, stderr'); -is($? >> 8, 111, 'ta-tool elasticsearch version, override, exit status'); + $testapp->run(args => 'info --target-version'); + like($testapp->stdout, qr/^6\.\d\.\d{1,2}$/, 'ta-tool elasticsearch version, stdout'); + like($testapp->stderr, qr/^$/, 'ta-tool elasticsearch version, stderr'); + is($? >> 8, 0, 'ta-tool elasticsearch version, exit status'); +}; +subtest 'overrides' => sub { + plan tests => 3; + $testapp->run(args => 'info --elasticsearch-host localhost --target-version'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^$/, 'ta-tool elasticsearch version, override, stdout'); + like($testapp->stderr, qr/^Hint: override local config/, 'ta-tool elasticsearch version, override, stderr'); + is($? >> 8, 111, 'ta-tool elasticsearch version, override, exit status'); +}; 1; diff --git a/t/03-report.t b/t/03-report.t index 07d2d6dac72e7a8e798fc73a309e097a63c6974c..ea0086b4db778a6c70f18a13b80cec61128f5be2 100644 --- a/t/03-report.t +++ b/t/03-report.t @@ -1,6 +1,6 @@ use v5.36; use Test::Cmd; -use Test::More tests =>27; +use Test::More tests => 3; use Path::Tiny; my $perl = $^X; my $testapp = Test::Cmd->new( @@ -27,58 +27,64 @@ password: 839852bed005a7f1237578a6ac1197c142f7d0dd58bb248446dc7849d4bf770902e7f9 user: lza _CFG_ # tests -note "help check"; -foreach my $param ("help report", "report -h", "report --help") { - $testapp->run(args => $param); +subtest 'help check' => sub { + plan tests => 9; + foreach my $param ("help report", "report -h", "report --help") { + $testapp->run(args => $param); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); + like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); + is($? >> 8, 0, "ta-tool $param, exit status"); + } +}; + +subtest 'check cli params' => sub { + plan tests => 15; + $testapp->run(args => 'report'); #say "STDOUT:",$testapp->stdout; #say "STDERR:",$testapp->stderr; - like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); - like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); - is($? >> 8, 0, "ta-tool $param, exit status"); -} - -note "check cli params"; -$testapp->run(args =>'report'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^:lang: en\n:doctype: article\n:date:.*\n:generator:.*\n:toc:\n\n= Report from.*\n\n== Complete archive\n\n=== count/s, 'ta-tool report, base, stdout'); -like($testapp->stderr, qr/^reporting for period/s, 'ta-tool report, base, stderr'); -is($? >> 8, 0, 'ta-tool report, base, exit status'); + like($testapp->stdout, qr/^:lang: en\n:doctype: article\n:date:.*\n:generator:.*\n:toc:\n\n= Report from.*\n\n== Complete archive\n\n=== count/s, 'ta-tool report, base, stdout'); + like($testapp->stderr, qr/^reporting for period/s, 'ta-tool report, base, stderr'); + is($? >> 8, 0, 'ta-tool report, base, exit status'); -$testapp->run(args =>'report --output-as-csv'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^"set","subset","timespan_from","timespan_to","aip_state","filter","flavour","value"\n"([a-z]+)",,"\d{4}-\d{2}-\d{2}","\d{4}-\d{2}-\d{2}","([a-z ]+)",,"([a-z ]+)",\d+(\.\d+)?\n/s, 'ta-tool report, base as CSV, stdout'); -like($testapp->stderr, qr/^reporting for period/s, 'ta-tool report, base as CSV, stderr'); -is($? >> 8, 0, 'ta-tool report, base as CSV, exit status'); - -$testapp->run(args =>'report --output-as-csv --with-ldp'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^"set","subset","timespan_from","timespan_to","aip_state","filter","flavour","value"\n.*LDP/s, 'ta-tool report, with ldp, stdout'); -like($testapp->stderr, qr/^reporting for period.*HINT:.*with-ldp/s, 'ta-tool report, with ldp, stderr'); -is($? >> 8, 0, 'ta-tool report, with ldp, exit status'); + $testapp->run(args => 'report --output-as-csv'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^"set","subset","timespan_from","timespan_to","aip_state","filter","flavour","value"\n"([a-z]+)",,"\d{4}-\d{2}-\d{2}","\d{4}-\d{2}-\d{2}","([a-z ]+)",,"([a-z ]+)",\d+(\.\d+)?\n/s, 'ta-tool report, base as CSV, stdout'); + like($testapp->stderr, qr/^reporting for period/s, 'ta-tool report, base as CSV, stderr'); + is($? >> 8, 0, 'ta-tool report, base as CSV, exit status'); -$testapp->run(args =>'report --output-as-csv --with-filetypes'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^"set","subset","timespan_from","timespan_to","aip_state","filter","flavour","value"\n.*total/s, 'ta-tool report, with filetype, stdout'); -like($testapp->stderr, qr/^reporting for period.*HINT:.*with-filetype/s, 'ta-tool report, with filetype, stderr'); -is($? >> 8, 0, 'ta-tool report, with filetype, exit status'); + $testapp->run(args => 'report --output-as-csv --with-ldp'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^"set","subset","timespan_from","timespan_to","aip_state","filter","flavour","value"\n.*LDP/s, 'ta-tool report, with ldp, stdout'); + like($testapp->stderr, qr/^reporting for period.*HINT:.*with-ldp/s, 'ta-tool report, with ldp, stderr'); + is($? >> 8, 0, 'ta-tool report, with ldp, exit status'); -$testapp->run(args =>'report --output-as-csv --with-ldp --with-filetypes'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^"set","subset","timespan_from","timespan_to","aip_state","filter","flavour","value"\n.*LDP/s, 'ta-tool report, with ldp and filetypes, stdout'); -like($testapp->stderr, qr/^reporting for period.*HINT:.*with-ldp.*with-filetype/s, 'ta-tool report, with ldp and filetypes, stderr'); -is($? >> 8, 0, 'ta-tool report, with ldp and filetypes, exit status'); + $testapp->run(args => 'report --output-as-csv --with-filetypes'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^"set","subset","timespan_from","timespan_to","aip_state","filter","flavour","value"\n.*total/s, 'ta-tool report, with filetype, stdout'); + like($testapp->stderr, qr/^reporting for period.*HINT:.*with-filetype/s, 'ta-tool report, with filetype, stderr'); + is($? >> 8, 0, 'ta-tool report, with filetype, exit status'); + $testapp->run(args => 'report --output-as-csv --with-ldp --with-filetypes'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^"set","subset","timespan_from","timespan_to","aip_state","filter","flavour","value"\n.*LDP/s, 'ta-tool report, with ldp and filetypes, stdout'); + like($testapp->stderr, qr/^reporting for period.*HINT:.*with-ldp.*with-filetype/s, 'ta-tool report, with ldp and filetypes, stderr'); + is($? >> 8, 0, 'ta-tool report, with ldp and filetypes, exit status'); +}; -note "overrides"; -$testapp->run(args =>'report --elasticsearch-host localhost'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^$/s, 'ta-tool report, base, stdout'); -like($testapp->stderr, qr/^Hint: override local config with/s, 'ta-tool report, base, stderr'); -is($? >> 8, 111, 'ta-tool report, base, exit status'); +subtest 'overrides' => sub { + plan tests => 3; + $testapp->run(args => 'report --elasticsearch-host localhost'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^$/s, 'ta-tool report, base, stdout'); + like($testapp->stderr, qr/^Hint: override local config with/s, 'ta-tool report, base, stderr'); + is($? >> 8, 111, 'ta-tool report, base, exit status'); +}; +1; diff --git a/t/03-search.t b/t/03-search.t index 2f86c76e0d49a985ff08c05fdfc4d69c5fdc2936..e96c8de1a33c1756f86f19ae73087ef5c74c204f 100644 --- a/t/03-search.t +++ b/t/03-search.t @@ -1,6 +1,6 @@ use v5.36; use Test::Cmd; -use Test::More tests =>111; +use Test::More tests =>11; use Path::Tiny; my $perl = $^X; my $testapp = Test::Cmd->new( @@ -27,158 +27,181 @@ password: 839852bed005a7f1237578a6ac1197c142f7d0dd58bb248446dc7849d4bf770902e7f9 user: lza _CFG_ # tests -note "help check"; -foreach my $param ("help search", "search -h", "search --help") { - $testapp->run(args => $param); +subtest 'help check' => sub { + plan tests => 9; + foreach my $param ("help search", "search -h", "search --help") { + $testapp->run(args => $param); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); + like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); + is($? >> 8, 0, "ta-tool $param, exit status"); + } +}; + +subtest 'check cli params' => sub { + plan tests => 3; + $testapp->run(args => 'search --lzaid SLUB:LZA:goobi:1 --debug'); #say "STDOUT:",$testapp->stdout; #say "STDERR:",$testapp->stderr; - like($testapp->stdout, qr/this usage screen/, "ta-tool $param, stdout"); - like($testapp->stderr, qr/^$/, "ta-tool $param, stderr"); - is($? >> 8, 0, "ta-tool $param, exit status"); -} - -note "check cli params"; -$testapp->run(args =>'search --lzaid SLUB:LZA:goobi:1 --debug'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr//, 'ta-tool search by lzaid, wrong format, stdout'); -like($testapp->stderr, qr/^$.*Error: --[a-z].* expects.*Usage/s, 'ta-tool search by lzaid, wrong format, stderr'); -isnt($? >> 8, 0, 'ta-tool search by lzaid, wrong format, exit status'); - - -note "elastic search non-existing lza id"; -$testapp->run(args =>'search --lzaid SLUB:LZA:Goobi:goobi:1 --debug'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A\s*\Z/s, 'ta-tool search by lzaid, no match, stdout'); -like($testapp->stderr, qr/\A\@must.*\@should.*query:.*found 0 results\Z/s, 'ta-tool search by lzaid, no match, stderr'); -is($? >> 8, 0, 'ta-tool search by lzaid, no match, exit status'); - -$testapp->run(args =>'search --lzaid SLUB:LZA:Goobi:goobi:1'); -like($testapp->stdout, qr/\A\s*\Z/s, 'ta-tool search by lzaid, no match, stdout'); -like($testapp->stderr, qr/^found 0 results$/, 'ta-tool search by lzaid, no match, stderr'); -is($? >> 8, 0, 'ta-tool search by lzaid, no match, exit status'); - -note "elastic search existing lza id"; -$testapp->run(args =>'search --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --debug'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A"aipid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2"\Z/s, 'ta-tool search by lzaid, existing, stdout'); -like($testapp->stderr, qr/\A\@must.*\@should.*query:.*found 1 result\nreporting results output as csv\Z/s, 'ta-tool search by lzaid, existing, stderr'); -is($? >> 8, 0, 'ta-tool search by lzaid, no match, exit status'); - -$testapp->run(args =>'search --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A"aipid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2"\Z/s, 'ta-tool search by lzaid, existing, stdout'); -like($testapp->stderr, qr/\Afound 1 result\nreporting results output as csv\Z/s, 'ta-tool search by lzaid, existing, stderr'); -is($? >> 8, 0, 'ta-tool search by lzaid, existing, exit status'); - -note "elastic search existing dc entry"; -$testapp->run(args =>'search --descriptive "Retrodigitalisierte Fotosn"');#SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A"aipid"\n"6ae5f1f0-5306-404f-8fb7-445f82416932"\n"9a254f9d-1c19-478a-aacb-43be3a3c7d9d"\n.*"4f7516e4-23c8-4750-a411-91359fb7a869"\Z/s, 'ta-tool search by dc, existing, stdout'); -like($testapp->stderr, qr/\Afound 30 results\nreporting results 1 … 10 output as csv\Z/s, 'ta-tool search by dc, existing, stderr'); -is($? >> 8, 0, 'ta-tool search by lzaid, existing, exit status'); - -note "check output formats"; -$testapp->run(args =>'search --output-as-raw --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 ' ); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A\{\n\s*hits\s*\{\n\s*hits\s*\[\n/s, 'ta-tool search, raw output, stdout'); -like($testapp->stderr, qr/\Afound 1 result\nreporting results output as raw\Z/s, 'ta-tool search, raw output, stderr'); -is($? >> 8, 0, 'ta-tool search, raw output, exit status'); - -$testapp->run(args =>'search --output-as-csv --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --with-lzaid' ); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A"aipid","slubarchiv_lzaid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2","SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111"\Z/s, 'ta-tool search, CSV output, stdout'); -like($testapp->stderr, qr/\Afound 1 result\nreporting results output as csv\Z/s, 'ta-tool search, CSV output, stderr'); -is($? >> 8, 0, 'ta-tool search, CSV output, exit status'); - -$testapp->run(args =>'search --output-as-rsv --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --with-lzaid' ); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\Aaipid\x{ff}slubarchiv_lzaid\x{ff}\x{fd}47daf26a-02a1-4776-a8db-de04c6708bd2\x{ff}SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111\x{ff}\x{fd}\Z/s, 'ta-tool search, RSV output, stdout'); -like($testapp->stderr, qr/\Afound 1 result\nreporting results output as rsv\Z/s, 'ta-tool search, RSV output, stderr'); -is($? >> 8, 0, 'ta-tool search, RSV output, exit status'); - -note "check with-options"; -foreach my $with (qw( - External-Description - External-Identifier - LDP-collection - LDP-funder - LDP-lender - LDP-project - SLUBArchiv-archivalValueDescription - SLUBArchiv-exportToArchiveDate - SLUBArchiv-externalId - SLUBArchiv-externalIsilId - SLUBArchiv-externalWorkflow - SLUBArchiv-hasConservationReason - SLUBArchiv-lzaId - SLUBArchiv-migrated-AIP - SLUBArchiv-origin-AIS - SLUBArchiv-previous-AIP - SLUBArchiv-rightsVersion - SLUBArchiv-sipVersion - Title -) ) { - my $with_opt = "--with-".lc($with); - my $head = lc($with); $head=~s/-/_/g; - $testapp->run(args => 'search --output-as-csv --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 '.$with_opt); + like($testapp->stdout, qr//, 'ta-tool search by lzaid, wrong format, stdout'); + like($testapp->stderr, qr/^$.*Error: --[a-z].* expects.*Usage/s, 'ta-tool search by lzaid, wrong format, stderr'); + isnt($? >> 8, 0, 'ta-tool search by lzaid, wrong format, exit status'); +}; + +subtest 'elastic search non-existing lza id' => sub { + plan tests => 6; + $testapp->run(args => 'search --lzaid SLUB:LZA:Goobi:goobi:1 --debug'); #say "STDOUT:",$testapp->stdout; #say "STDERR:",$testapp->stderr; - like($testapp->stdout, qr/\A"aipid","$head"\n"47daf26a-02a1-4776-a8db-de04c6708bd2",("[A-Za-zäöüßÄÖÜ0-9_:. -]*")|\d+(\.\d+)?\Z/s, 'ta-tool search, check "'.$with_opt.'", stdout'); - like($testapp->stderr, qr/\Afound 1 result\nreporting results output as csv\Z/s, 'ta-tool search, check "'.$with_opt.'", stderr'); - is($? >> 8, 0, 'ta-tool search, check "'.$with_opt.'", exit status'); -} -note "search by files"; -$testapp->run(args =>'search --pronom-id fmt/101'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A"aipid"\n.*"47daf26a-02a1-4776-a8db-de04c6708bd2"/s, 'ta-tool search by pronom-id, existing, stdout'); -like($testapp->stderr, qr/\Afound 166 results\nreporting results 1 … 10 output as csv\Z/s, 'ta-tool search by pronom-id, existing, stderr'); -is($? >> 8, 0, 'ta-tool search by pronom-id, existing, exit status'); - -note "check paginations"; -$testapp->run(args =>'search --pronom-id fmt/101 --with-result-index --output-as-csv --startrecord 2 --maxrecords 1'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A"idx","aipid"\n2,"2ed0c682-4565-4320-8247-6da0cc0642f1"\Z/s, 'ta-tool search by pronom-id, existing, stdout'); -like($testapp->stderr, qr/\Afound 166 results\nreporting results output as csv\Z/s, 'ta-tool search by pronom-id, existing, stderr'); -is($? >> 8, 0, 'ta-tool search by pronom-id, existing, exit status'); - -$testapp->run(args =>'search --pronom-id fmt/101 --with-result-index --output-as-csv --startrecord 3 --maxrecords 2'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A"idx","aipid"\n3,"5687a403-673d-45c1-864f-f7f22a7aadb9"\n4,"db256475-10bd-40ee-83cc-dab8424346ba"\Z/s, 'ta-tool search by pronom-id, existing, stdout'); -like($testapp->stderr, qr/\Afound 166 results\nreporting results 3 … 4 output as csv\Z/s, 'ta-tool search by pronom-id, existing, stderr'); -is($? >> 8, 0, 'ta-tool search by pronom-id, existing, exit status'); - -note "search dates"; -$testapp->run(args =>'search --creationdate 2023-09-05'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A"aipid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2"\n"e8bfdec5-d201-42d6-b293-94bb1668a7b6"\Z/s, 'ta-tool search date, existing, stdout'); -like($testapp->stderr, qr/\Afound 2 results\nreporting results 1 … 2 output as csv/s, 'ta-tool search date, existing, stderr'); -is($? >> 8, 0, 'ta-tool search date, existing, exit status'); - -$testapp->run(args =>'search --creationdate-from 2023-09-05 --creationdate-to 2023-12-22'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/\A"aipid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2"\n/s, 'ta-tool search dates, existing, stdout'); -like($testapp->stderr, qr/\Afound 25 results\nreporting results 1 … 10 output as csv/s, 'ta-tool search dates, existing, stderr'); -is($? >> 8, 0, 'ta-tool search dates, existing, exit status'); - -note "overrides"; -$testapp->run(args =>'search --elasticsearch-host localhost --creationdate-from 2023-09-05 --creationdate-to 2023-12-22'); -#say "STDOUT:",$testapp->stdout; -#say "STDERR:",$testapp->stderr; -like($testapp->stdout, qr/^$/s, 'ta-tool search dates, existing, override, stdout'); -like($testapp->stderr, qr/^Hint: override local config with/s, 'ta-tool search dates, existing, override stderr'); -is($? >> 8, 111, 'ta-tool search dates, existing, override, exit status'); + like($testapp->stdout, qr/\A\s*\Z/s, 'ta-tool search by lzaid, no match, stdout'); + like($testapp->stderr, qr/\A\@must.*\@should.*query:.*found 0 results\Z/s, 'ta-tool search by lzaid, no match, stderr'); + is($? >> 8, 0, 'ta-tool search by lzaid, no match, exit status'); + + $testapp->run(args => 'search --lzaid SLUB:LZA:Goobi:goobi:1'); + like($testapp->stdout, qr/\A\s*\Z/s, 'ta-tool search by lzaid, no match, stdout'); + like($testapp->stderr, qr/^found 0 results$/, 'ta-tool search by lzaid, no match, stderr'); + is($? >> 8, 0, 'ta-tool search by lzaid, no match, exit status'); +}; + +subtest 'elastic search existing lza id' => sub { + plan tests => 6; + $testapp->run(args => 'search --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --debug'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"aipid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2"\Z/s, 'ta-tool search by lzaid, existing, stdout'); + like($testapp->stderr, qr/\A\@must.*\@should.*query:.*found 1 result\nreporting results output as csv\Z/s, 'ta-tool search by lzaid, existing, stderr'); + is($? >> 8, 0, 'ta-tool search by lzaid, no match, exit status'); + + $testapp->run(args => 'search --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"aipid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2"\Z/s, 'ta-tool search by lzaid, existing, stdout'); + like($testapp->stderr, qr/\Afound 1 result\nreporting results output as csv\Z/s, 'ta-tool search by lzaid, existing, stderr'); + is($? >> 8, 0, 'ta-tool search by lzaid, existing, exit status'); +}; + +subtest 'elastic search existing dc entry' => sub { + plan tests => 3; + $testapp->run(args => 'search --descriptive "Retrodigitalisierte Fotosn"'); #SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"aipid"\n"6ae5f1f0-5306-404f-8fb7-445f82416932"\n"9a254f9d-1c19-478a-aacb-43be3a3c7d9d"\n.*"4f7516e4-23c8-4750-a411-91359fb7a869"\Z/s, 'ta-tool search by dc, existing, stdout'); + like($testapp->stderr, qr/\Afound 30 results\nreporting results 1 … 10 output as csv\Z/s, 'ta-tool search by dc, existing, stderr'); + is($? >> 8, 0, 'ta-tool search by lzaid, existing, exit status'); +}; + +subtest 'check output formats' => sub { + plan tests => 9; + $testapp->run(args => 'search --output-as-raw --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 '); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A\{\n\s*hits\s*\{\n\s*hits\s*\[\n/s, 'ta-tool search, raw output, stdout'); + like($testapp->stderr, qr/\Afound 1 result\nreporting results output as raw\Z/s, 'ta-tool search, raw output, stderr'); + is($? >> 8, 0, 'ta-tool search, raw output, exit status'); + + $testapp->run(args => 'search --output-as-csv --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --with-lzaid'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"aipid","slubarchiv_lzaid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2","SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111"\Z/s, 'ta-tool search, CSV output, stdout'); + like($testapp->stderr, qr/\Afound 1 result\nreporting results output as csv\Z/s, 'ta-tool search, CSV output, stderr'); + is($? >> 8, 0, 'ta-tool search, CSV output, exit status'); + + $testapp->run(args => 'search --output-as-rsv --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --with-lzaid'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\Aaipid\x{ff}slubarchiv_lzaid\x{ff}\x{fd}47daf26a-02a1-4776-a8db-de04c6708bd2\x{ff}SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111\x{ff}\x{fd}\Z/s, 'ta-tool search, RSV output, stdout'); + like($testapp->stderr, qr/\Afound 1 result\nreporting results output as rsv\Z/s, 'ta-tool search, RSV output, stderr'); + is($? >> 8, 0, 'ta-tool search, RSV output, exit status'); +}; + +subtest 'check with-options' => sub { + plan tests => 57; + foreach my $with (qw( + External-Description + External-Identifier + LDP-collection + LDP-funder + LDP-lender + LDP-project + SLUBArchiv-archivalValueDescription + SLUBArchiv-exportToArchiveDate + SLUBArchiv-externalId + SLUBArchiv-externalIsilId + SLUBArchiv-externalWorkflow + SLUBArchiv-hasConservationReason + SLUBArchiv-lzaId + SLUBArchiv-migrated-AIP + SLUBArchiv-origin-AIS + SLUBArchiv-previous-AIP + SLUBArchiv-rightsVersion + SLUBArchiv-sipVersion + Title + )) { + my $with_opt = "--with-" . lc($with); + my $head = lc($with); + $head =~ s/-/_/g; + $testapp->run(args => 'search --output-as-csv --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 ' . $with_opt); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"aipid","$head"\n"47daf26a-02a1-4776-a8db-de04c6708bd2",("[A-Za-zäöüßÄÖÜ0-9_:. -]*")|\d+(\.\d+)?\Z/s, 'ta-tool search, check "' . $with_opt . '", stdout'); + like($testapp->stderr, qr/\Afound 1 result\nreporting results output as csv\Z/s, 'ta-tool search, check "' . $with_opt . '", stderr'); + is($? >> 8, 0, 'ta-tool search, check "' . $with_opt . '", exit status'); + } +}; + +subtest 'search by files' => sub { + plan tests => 3; + $testapp->run(args => 'search --pronom-id fmt/101'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"aipid"\n.*"47daf26a-02a1-4776-a8db-de04c6708bd2"/s, 'ta-tool search by pronom-id, existing, stdout'); + like($testapp->stderr, qr/\Afound 166 results\nreporting results 1 … 10 output as csv\Z/s, 'ta-tool search by pronom-id, existing, stderr'); + is($? >> 8, 0, 'ta-tool search by pronom-id, existing, exit status'); +}; + +subtest 'check paginations' => sub { + plan tests => 6; + $testapp->run(args => 'search --pronom-id fmt/101 --with-result-index --output-as-csv --startrecord 2 --maxrecords 1'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"idx","aipid"\n2,"2ed0c682-4565-4320-8247-6da0cc0642f1"\Z/s, 'ta-tool search by pronom-id, existing, stdout'); + like($testapp->stderr, qr/\Afound 166 results\nreporting results output as csv\Z/s, 'ta-tool search by pronom-id, existing, stderr'); + is($? >> 8, 0, 'ta-tool search by pronom-id, existing, exit status'); + + $testapp->run(args => 'search --pronom-id fmt/101 --with-result-index --output-as-csv --startrecord 3 --maxrecords 2'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"idx","aipid"\n3,"5687a403-673d-45c1-864f-f7f22a7aadb9"\n4,"db256475-10bd-40ee-83cc-dab8424346ba"\Z/s, 'ta-tool search by pronom-id, existing, stdout'); + like($testapp->stderr, qr/\Afound 166 results\nreporting results 3 … 4 output as csv\Z/s, 'ta-tool search by pronom-id, existing, stderr'); + is($? >> 8, 0, 'ta-tool search by pronom-id, existing, exit status'); +}; + +subtest 'search dates' => sub { + plan tests => 6; + $testapp->run(args => 'search --creationdate 2023-09-05'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"aipid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2"\n"e8bfdec5-d201-42d6-b293-94bb1668a7b6"\Z/s, 'ta-tool search date, existing, stdout'); + like($testapp->stderr, qr/\Afound 2 results\nreporting results 1 … 2 output as csv/s, 'ta-tool search date, existing, stderr'); + is($? >> 8, 0, 'ta-tool search date, existing, exit status'); + + $testapp->run(args => 'search --creationdate-from 2023-09-05 --creationdate-to 2023-12-22'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/\A"aipid"\n"47daf26a-02a1-4776-a8db-de04c6708bd2"\n/s, 'ta-tool search dates, existing, stdout'); + like($testapp->stderr, qr/\Afound 25 results\nreporting results 1 … 10 output as csv/s, 'ta-tool search dates, existing, stderr'); + is($? >> 8, 0, 'ta-tool search dates, existing, exit status'); +}; + +subtest 'overrides' => sub { + plan tests => 3; + $testapp->run(args => 'search --elasticsearch-host localhost --creationdate-from 2023-09-05 --creationdate-to 2023-12-22'); + #say "STDOUT:",$testapp->stdout; + #say "STDERR:",$testapp->stderr; + like($testapp->stdout, qr/^$/s, 'ta-tool search dates, existing, override, stdout'); + like($testapp->stderr, qr/^Hint: override local config with/s, 'ta-tool search dates, existing, override stderr'); + is($? >> 8, 111, 'ta-tool search dates, existing, override, exit status'); +}; 1;