Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tests quieter #1193

Merged
merged 3 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 0 additions & 103 deletions bin/build_test_CPAN_dir.pl

This file was deleted.

8 changes: 4 additions & 4 deletions lib/MetaCPAN/Script/Mapping.pm
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,16 @@ sub delete_index {
sub delete_all {
my $self = $_[0];
my $runtime_environment = 'production';
my $is_development = 0;

$runtime_environment = $ENV{'PLACK_ENV'}
if ( defined $ENV{'PLACK_ENV'} );
$runtime_environment = $ENV{'MOJO_MODE'}
if ( defined $ENV{'MOJO_MODE'} );

$is_development = 1
if ( $runtime_environment eq 'development'
|| $runtime_environment eq 'testing' );
my $is_development
= $ENV{HARNESS_ACTIVE}
|| $runtime_environment eq 'development'
|| $runtime_environment eq 'testing';

if ($is_development) {
my $name = undef;
Expand Down
119 changes: 0 additions & 119 deletions t/lib/MetaCPAN/TestServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ sub setup {

$self->es_client;

# Run the Delete Index Tests before mapping deployment
$self->test_delete_mappings;

# Deploy project mappings
$self->put_mappings;
}
Expand Down Expand Up @@ -355,102 +352,6 @@ sub prepare_user_test_data {
);
}

sub test_delete_mappings {
my $self = $_[0];

$self->test_delete_fails;
$self->test_delete_all;
}

sub test_delete_fails {
my $self = $_[0];

my $iexitcode;
my $irunok;

subtest 'delete all not permitted' => sub {

# mapping script - delete indices
{
local @ARGV = qw(mapping --delete --all);
local %ENV = (%ENV);

delete $ENV{'PLACK_ENV'};
delete $ENV{'MOJO_MODE'};

$irunok = MetaCPAN::Script::Runner::run;
$iexitcode = $MetaCPAN::Script::Runner::EXIT_CODE;
}

ok( !$irunok, "delete all fails" );
is( $iexitcode, 1, "Exit Code '1' - Permission Error" );
};
}

sub test_delete_all {
my $self = $_[0];

subtest 'delete all deletes unknown index' => sub {
subtest 'create index' => sub {
my $smockindexjson = q({
"mock_index" : {
"properties" : {
"mock_field" : {
"index" : "not_analyzed",
"ignore_above" : 2048,
"type" : "string"
}
}
}
});

local @ARGV = (
'mapping', '--create_index',
'mock_index', '--patch_mapping',
$smockindexjson
);

ok(
MetaCPAN::Script::Runner::run,
"creation 'mock_index' succeeds"
);
is( $MetaCPAN::Script::Runner::EXIT_CODE,
0, "Exit Code '0' - No Error" );
};
subtest 'info shows unknonwn index' => sub {
local @ARGV = ( 'mapping', '--show_cluster_info' );
my $mapping = MetaCPAN::Script::Mapping->new_with_options(
$self->_config );

ok( $mapping->run, "show info succeeds" );
is( $mapping->exit_code, 0, "Exit Code '0' - No Error" );

ok( defined $mapping->indices_info, 'Index Info built' );
ok( defined $mapping->indices_info->{'mock_index'},
'Unknown Index printed' );
};
subtest 'delete all succeeds' => sub {
local @ARGV = qw(mapping --delete --all);

ok( MetaCPAN::Script::Runner::run, "delete all succeeds" );
is( $MetaCPAN::Script::Runner::EXIT_CODE,
0, "Exit Code '0' - No Error" );
};
subtest 'info does not show unknown index' => sub {
local @ARGV = ( 'mapping', '--show_cluster_info' );
my $mapping = MetaCPAN::Script::Mapping->new_with_options(
$self->_config );

ok( $mapping->run, "show info succeeds" );
is( $mapping->exit_code, 0, "Exit Code '0' - No Error" );

ok( defined $mapping->indices_info, 'Index Info built' );
ok( !defined $mapping->indices_info->{'mock_index'},
'Unknown Index not printed' );
};
};
}

sub test_mappings {
my $self = $_[0];

Expand All @@ -473,16 +374,6 @@ sub test_index_missing {
ok( $mapping->run, "deletion 'cover' succeeds" );
is( $mapping->exit_code, 0, "Exit Code '0' - No Error" );
};
subtest 'mapping verification fails' => sub {
local @ARGV = qw(mapping --verify);
my $mapping
= MetaCPAN::Script::Mapping->new_with_options(
$self->_config );

is( $mapping->run, 0, "verification execution fails" );
is( $mapping->exit_code, 1,
"Exit Code '1' - Verification Error" );
};
subtest 're-create cover index' => sub {
local @ARGV = (
'mapping', '--create_index',
Expand Down Expand Up @@ -536,16 +427,6 @@ sub test_field_mismatch {

is( $mapping->exit_code, 0, "Exit Code '0' - No Error" );
};
subtest 'field verification fails' => sub {
local @ARGV = qw(mapping --verify);
my $mapping
= MetaCPAN::Script::Mapping->new_with_options(
$self->_config );

is( $mapping->run, 0, "verification fails" );
is( $mapping->exit_code, 1,
"Exit Code '1' - Verification Error" );
};
subtest 'mapping re-establish field' => sub {
local @ARGV = (
'mapping', '--update_index',
Expand Down