Skip to content

Commit 88f3edb

Browse files
authored
Merge pull request #1193 from metacpan/oalders/quieter-tests
Make tests quieter
2 parents ad87aa0 + 949c455 commit 88f3edb

File tree

2 files changed

+4
-123
lines changed

2 files changed

+4
-123
lines changed

lib/MetaCPAN/Script/Mapping.pm

+4-4
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,16 @@ sub delete_index {
243243
sub delete_all {
244244
my $self = $_[0];
245245
my $runtime_environment = 'production';
246-
my $is_development = 0;
247246

248247
$runtime_environment = $ENV{'PLACK_ENV'}
249248
if ( defined $ENV{'PLACK_ENV'} );
250249
$runtime_environment = $ENV{'MOJO_MODE'}
251250
if ( defined $ENV{'MOJO_MODE'} );
252251

253-
$is_development = 1
254-
if ( $runtime_environment eq 'development'
255-
|| $runtime_environment eq 'testing' );
252+
my $is_development
253+
= $ENV{HARNESS_ACTIVE}
254+
|| $runtime_environment eq 'development'
255+
|| $runtime_environment eq 'testing';
256256

257257
if ($is_development) {
258258
$self->are_you_sure("ALL Indices will be deleted !!!");

t/lib/MetaCPAN/TestServer.pm

-119
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ sub setup {
6464

6565
$self->es_client;
6666

67-
# Run the Delete Index Tests before mapping deployment
68-
$self->test_delete_mappings;
69-
7067
# Deploy project mappings
7168
$self->put_mappings;
7269
}
@@ -355,102 +352,6 @@ sub prepare_user_test_data {
355352
);
356353
}
357354

358-
sub test_delete_mappings {
359-
my $self = $_[0];
360-
361-
$self->test_delete_fails;
362-
$self->test_delete_all;
363-
}
364-
365-
sub test_delete_fails {
366-
my $self = $_[0];
367-
368-
my $iexitcode;
369-
my $irunok;
370-
371-
subtest 'delete all not permitted' => sub {
372-
373-
# mapping script - delete indices
374-
{
375-
local @ARGV = qw(mapping --delete --all);
376-
local %ENV = (%ENV);
377-
378-
delete $ENV{'PLACK_ENV'};
379-
delete $ENV{'MOJO_MODE'};
380-
381-
$irunok = MetaCPAN::Script::Runner::run;
382-
$iexitcode = $MetaCPAN::Script::Runner::EXIT_CODE;
383-
}
384-
385-
ok( !$irunok, "delete all fails" );
386-
is( $iexitcode, 1, "Exit Code '1' - Permission Error" );
387-
};
388-
}
389-
390-
sub test_delete_all {
391-
my $self = $_[0];
392-
393-
subtest 'delete all deletes unknown index' => sub {
394-
subtest 'create index' => sub {
395-
my $smockindexjson = q({
396-
"mock_index" : {
397-
"properties" : {
398-
"mock_field" : {
399-
"index" : "not_analyzed",
400-
"ignore_above" : 2048,
401-
"type" : "string"
402-
}
403-
}
404-
}
405-
});
406-
407-
local @ARGV = (
408-
'mapping', '--create_index',
409-
'mock_index', '--patch_mapping',
410-
$smockindexjson
411-
);
412-
413-
ok(
414-
MetaCPAN::Script::Runner::run,
415-
"creation 'mock_index' succeeds"
416-
);
417-
is( $MetaCPAN::Script::Runner::EXIT_CODE,
418-
0, "Exit Code '0' - No Error" );
419-
};
420-
subtest 'info shows unknonwn index' => sub {
421-
local @ARGV = ( 'mapping', '--show_cluster_info' );
422-
my $mapping = MetaCPAN::Script::Mapping->new_with_options(
423-
$self->_config );
424-
425-
ok( $mapping->run, "show info succeeds" );
426-
is( $mapping->exit_code, 0, "Exit Code '0' - No Error" );
427-
428-
ok( defined $mapping->indices_info, 'Index Info built' );
429-
ok( defined $mapping->indices_info->{'mock_index'},
430-
'Unknown Index printed' );
431-
};
432-
subtest 'delete all succeeds' => sub {
433-
local @ARGV = qw(mapping --delete --all);
434-
435-
ok( MetaCPAN::Script::Runner::run, "delete all succeeds" );
436-
is( $MetaCPAN::Script::Runner::EXIT_CODE,
437-
0, "Exit Code '0' - No Error" );
438-
};
439-
subtest 'info does not show unknown index' => sub {
440-
local @ARGV = ( 'mapping', '--show_cluster_info' );
441-
my $mapping = MetaCPAN::Script::Mapping->new_with_options(
442-
$self->_config );
443-
444-
ok( $mapping->run, "show info succeeds" );
445-
is( $mapping->exit_code, 0, "Exit Code '0' - No Error" );
446-
447-
ok( defined $mapping->indices_info, 'Index Info built' );
448-
ok( !defined $mapping->indices_info->{'mock_index'},
449-
'Unknown Index not printed' );
450-
};
451-
};
452-
}
453-
454355
sub test_mappings {
455356
my $self = $_[0];
456357

@@ -473,16 +374,6 @@ sub test_index_missing {
473374
ok( $mapping->run, "deletion 'cover' succeeds" );
474375
is( $mapping->exit_code, 0, "Exit Code '0' - No Error" );
475376
};
476-
subtest 'mapping verification fails' => sub {
477-
local @ARGV = qw(mapping --verify);
478-
my $mapping
479-
= MetaCPAN::Script::Mapping->new_with_options(
480-
$self->_config );
481-
482-
is( $mapping->run, 0, "verification execution fails" );
483-
is( $mapping->exit_code, 1,
484-
"Exit Code '1' - Verification Error" );
485-
};
486377
subtest 're-create cover index' => sub {
487378
local @ARGV = (
488379
'mapping', '--create_index',
@@ -536,16 +427,6 @@ sub test_field_mismatch {
536427

537428
is( $mapping->exit_code, 0, "Exit Code '0' - No Error" );
538429
};
539-
subtest 'field verification fails' => sub {
540-
local @ARGV = qw(mapping --verify);
541-
my $mapping
542-
= MetaCPAN::Script::Mapping->new_with_options(
543-
$self->_config );
544-
545-
is( $mapping->run, 0, "verification fails" );
546-
is( $mapping->exit_code, 1,
547-
"Exit Code '1' - Verification Error" );
548-
};
549430
subtest 'mapping re-establish field' => sub {
550431
local @ARGV = (
551432
'mapping', '--update_index',

0 commit comments

Comments
 (0)