From c5c4315d29f1e96e9298afc101c5e3e86e5a6c93 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 31 Jan 2017 09:11:05 +0100 Subject: [PATCH] Bug 18014: Add test to AuthoritiesMarc.t to expose problem in AddAuthority Since AddAuthority uses max(id)+1 logic to produce the next authid, authority id's will be reused when you delete the last record. This may be a source of problems and will be addressed on the next patch. This patch add a test to expose the problem. Test plan: [1] Run t/db_dependent/AuthoritiesMarc.t Signed-off-by: Marcel de Rooy Signed-off-by: Mark Tompsett --- t/db_dependent/AuthoritiesMarc.t | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/AuthoritiesMarc.t b/t/db_dependent/AuthoritiesMarc.t index da8241d..91025cf 100755 --- a/t/db_dependent/AuthoritiesMarc.t +++ b/t/db_dependent/AuthoritiesMarc.t @@ -5,7 +5,7 @@ use Modern::Perl; -use Test::More tests => 8; +use Test::More tests => 9; use Test::MockModule; use Test::Warn; use MARC::Record; @@ -191,4 +191,16 @@ is_deeply( 'test BuildSummary for UNIMARC' ); +subtest 'AddAuthority should respect AUTO_INCREMENT (BZ 18104)' => sub { + plan tests => 1; + + t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); + my $record = C4::AuthoritiesMarc::GetAuthority(1); + my $id1 = AddAuthority( $record, undef, 'GEOGR_NAME' ); + DelAuthority( $id1 ); + my $id2 = AddAuthority( $record, undef, 'GEOGR_NAME' ); + is( $id1, $id2, 'FIXME: Got the same id back, let\'s fix that behavior' ); + +}; + $schema->storage->txn_rollback; -- 2.1.4