Debian Codegraph @

t/13-empty-test-dir.t

raw
1 # vim: set ts=8 sts=2 sw=2 tw=100 et :
2 use strict;
3 use warnings;
4 use 5.020;
5 use strictures 2;
6 use stable 0.031 'postderef';
7 use experimental 'signatures';
8 no autovivification warn => qw(fetch store exists delete);
9 use if "$]" >= 5.022, experimental => 're_strict';
10 no if "$]" >= 5.031009, feature => 'indirect';
11 no if "$]" >= 5.033001, feature => 'multidimensional';
12 no if "$]" >= 5.033006, feature => 'bareword_filehandles';
13 no if "$]" >= 5.041009, feature => 'smartmatch';
14
15 use Test2::API 'intercept';
16 use Test2::V0 -no_pragmas => 1;
17 use if $ENV{AUTHOR_TESTING}, 'Test2::Warnings';
18 use Test::JSON::Schema::Acceptance;
19 use Test::File::ShareDir -share => { -dist => { 'Test-JSON-Schema-Acceptance' => 'share' } };
20
21 use lib 't/lib';
22 use SchemaParser;
23
24 my $accepter = Test::JSON::Schema::Acceptance->new(
25 test_dir => 't/tests/empty',
26 include_optional => 1,
27 );
28
29 is(@{$accepter->_test_data}, 0, 'an empty test directory means no test data');
30
31 my $parser = SchemaParser->new;
32 my $events = intercept(
33 sub {
34 $accepter->acceptance(sub ($schema, $data) {
35 return $parser->validate_data($data, $schema);
36 });
37 }
38 );
39
40 is(
41 scalar(grep exists $_->{assert}, map $_->facet_data, @$events),
42 0,
43 'no tests are run when test directory is empty',
44 );
45
46 done_testing;