blob: 89577fb58b1deee262875f308b290fe929decb10 [file] [log] [blame]
Akrona3f74f52024-07-17 17:18:17 +02001#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5use File::Basename;
6use File::Spec::Functions;
7use Data::Dumper;
Akronb31321e2024-07-18 11:17:46 +02008use File::Temp qw/tempdir/;
Akrona3f74f52024-07-17 17:18:17 +02009
10use Test::Output;
11use Mojo::JSON 'decode_json';
12
13my $script = catfile(dirname(__FILE__), '..', 'script', 'cosmasvc2koralquery');
Akronb31321e2024-07-18 11:17:46 +020014my $copysrc = catdir(dirname(__FILE__), 'data');
Akrona3f74f52024-07-17 17:18:17 +020015my $list1 = catfile(dirname(__FILE__), 'data', 'list-example.ls');
Akronb31321e2024-07-18 11:17:46 +020016my $output = tempdir( CLEANUP => 1 );
17
18my @call = ($script, 'list', $list1, '--copy-src', $copysrc, '--output', $output);
Akrona3f74f52024-07-17 17:18:17 +020019
20# Check STDOUT
Akronb31321e2024-07-18 11:17:46 +020021stderr_like(
Akrona3f74f52024-07-17 17:18:17 +020022 sub {
Akronb31321e2024-07-18 11:17:46 +020023 system(@call);
Akrona3f74f52024-07-17 17:18:17 +020024 },
Akronb31321e2024-07-18 11:17:46 +020025 qr!redabs is not yet supported!,
Akrona3f74f52024-07-17 17:18:17 +020026 "check stdout"
27);
28
29# Check JSON
Akronb31321e2024-07-18 11:17:46 +020030my $protocol = join('', `@call`);
31
32like($protocol, qr!bih from regex!);
33ok(-f catfile($output, 'bih.json'));
34like($protocol, qr!bio from regex!);
35ok(-f catfile($output, 'bio.json'));
36like($protocol, qr!bio-pub from regex!);
37ok(-f catfile($output, 'bio-pub.json'));
38like($protocol, qr!l from regex!);
39ok(-f catfile($output, 'l.json'));
40like($protocol, qr!dpa from regex!);
41ok(-f catfile($output, 'dpa.json'));
42like($protocol, qr!fsp from regex!);
43ok(-f catfile($output, 'fsp.json'));
44like($protocol, qr!fsp-pub from regex!);
45ok(-f catfile($output, 'fsp-pub.json'));
46like($protocol, qr!kjl from regex!);
47ok(-f catfile($output, 'kjl.json'));
48like($protocol, qr!thm-lit from regex!);
49ok(-f catfile($output, 'thm-lit.json'));
50like($protocol, qr!wxx11 from regex!);
51ok(-f catfile($output, 'wxx11.json'));
52like($protocol, qr!zca from regex!);
53ok(-f catfile($output, 'zca.json'));
54like($protocol, qr!list2 from def-file!);
55ok(-f catfile($output, 'list2.json'));
56like($protocol, qr!list5 from def-file!);
57ok(-f catfile($output, 'list5.json'));
58like($protocol, qr!misc-lit from regex!);
59ok(-f catfile($output, 'misc-lit.json'));
Akrona3f74f52024-07-17 17:18:17 +020060
61done_testing;
62__END__
Akronb31321e2024-07-18 11:17:46 +020063
64