Bug 16994: (QA follow-up) Align overwrite result key across module, template and tests
The import result hash key was inconsistent: the module sets
$result->{overwrote}, but the test checked $result->{overwrite} and the
template wrapper used import_overwrite. The uninitialized key also
triggered a "Use of uninitialized value" warning when no templates were
overwritten.
- Initialize overwrote => 0 in ImportModificationTemplates result hash
- Update test to check $result->{overwrote}
- Fix template success-alert wrapper to gate on import_overwrote
Test plan:
- prove t/db_dependent/MarcModificationTemplates.t
- all 134 subtests pass
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
7e1aff13ef
commit
a81b2cfe4f
|
|
@ -840,9 +840,10 @@ sub ImportModificationTemplates {
|
|||
my ( $json, $skip_existing ) = @_;
|
||||
|
||||
my $result = {
|
||||
success => 0,
|
||||
skipped => 0,
|
||||
errors => [],
|
||||
success => 0,
|
||||
skipped => 0,
|
||||
overwrote => 0,
|
||||
errors => [],
|
||||
};
|
||||
|
||||
my $data;
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@
|
|||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% IF import_success || import_skipped || import_overwrite %]
|
||||
[% IF import_success || import_skipped || import_overwrote %]
|
||||
<div class="alert alert-success">
|
||||
[% IF import_success %]
|
||||
<p>Successfully imported [% import_success | html %] template(s).</p>
|
||||
|
|
|
|||
|
|
@ -1236,7 +1236,7 @@ subtest 'Import with skip_existing=0 overwrites existing templates' => sub {
|
|||
my $result = ImportModificationTemplates( $json, 0 );
|
||||
ok( $result->{success} == 1, "Template imported successfully with skip_existing=0" );
|
||||
ok( $result->{skipped} == 0, "No templates skipped" );
|
||||
ok( $result->{overwrite} == 1, "One template overwritten" );
|
||||
ok( $result->{overwrote} == 1, "One template overwritten" );
|
||||
ok( scalar( @{ $result->{errors} } ) == 0, "No import errors" );
|
||||
|
||||
# Verify the template was overwritten (should have only 1 action now)
|
||||
|
|
|
|||
Loading…
Reference in New Issue