blob: 1cbd29b16fa669968c0cde6d579c012f2dd79a75 [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!);
Akroncaf9e442024-07-26 12:19:15 +020033ok(-f catfile($output, 'bih.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020034like($protocol, qr!bio from regex!);
Akroncaf9e442024-07-26 12:19:15 +020035ok(-f catfile($output, 'bio.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020036like($protocol, qr!bio-pub from regex!);
Akroncaf9e442024-07-26 12:19:15 +020037ok(-f catfile($output, 'bio-pub.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020038like($protocol, qr!l from regex!);
Akroncaf9e442024-07-26 12:19:15 +020039ok(-f catfile($output, 'l.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020040like($protocol, qr!dpa from regex!);
Akroncaf9e442024-07-26 12:19:15 +020041ok(-f catfile($output, 'dpa.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020042like($protocol, qr!fsp from regex!);
Akroncaf9e442024-07-26 12:19:15 +020043ok(-f catfile($output, 'fsp.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020044like($protocol, qr!fsp-pub from regex!);
Akroncaf9e442024-07-26 12:19:15 +020045ok(-f catfile($output, 'fsp-pub.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020046like($protocol, qr!kjl from regex!);
Akroncaf9e442024-07-26 12:19:15 +020047ok(-f catfile($output, 'kjl.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020048like($protocol, qr!thm-lit from regex!);
Akroncaf9e442024-07-26 12:19:15 +020049ok(-f catfile($output, 'thm-lit.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020050like($protocol, qr!wxx11 from regex!);
Akroncaf9e442024-07-26 12:19:15 +020051ok(-f catfile($output, 'wxx11.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020052like($protocol, qr!zca from regex!);
Akroncaf9e442024-07-26 12:19:15 +020053ok(-f catfile($output, 'zca.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020054like($protocol, qr!list2 from def-file!);
Akroncaf9e442024-07-26 12:19:15 +020055ok(-f catfile($output, 'list2.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020056like($protocol, qr!list5 from def-file!);
Akroncaf9e442024-07-26 12:19:15 +020057ok(-f catfile($output, 'list5.jsonld'));
Akronb31321e2024-07-18 11:17:46 +020058like($protocol, qr!misc-lit from regex!);
Akroncaf9e442024-07-26 12:19:15 +020059ok(-f catfile($output, 'misc-lit.jsonld'));
Akrona3f74f52024-07-17 17:18:17 +020060
61done_testing;
62__END__
Akronb31321e2024-07-18 11:17:46 +020063
64