Bugzilla – Attachment 44648 Details for
Bug 15159
TestBuilder behaviour on AI values should be tested
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15159: TestBuilder behaviour on AI values should be tested
Bug-15159-TestBuilder-behaviour-on-AI-values-shoul.patch (text/plain), 2.26 KB, created by
Tomás Cohen Arazi (tcohen)
on 2015-11-09 14:20:33 UTC
(
hide
)
Description:
Bug 15159: TestBuilder behaviour on AI values should be tested
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2015-11-09 14:20:33 UTC
Size:
2.26 KB
patch
obsolete
>From 3b8fbeb2aa0478be9998a8dc81dce5bf9084f1d9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 9 Nov 2015 11:15:36 -0300 >Subject: [PATCH] Bug 15159: TestBuilder behaviour on AI values should be > tested > >This patch introduces a test for t::lib::TestBuilder to check it >doesn't mess with AI values. As it is generating random values based >on the defined column type, chances are that it is creating the >AI values on its own, instead of letting the DB handle it. > >This could be problematic of course. This test uses the 'biblio' table >by creating two values and checking their biblionumbers are consecutive. > >To test: >- Apply the patch >- Run: > $ prove t/db_dependent/TestBuilder.t -v >=> SUCCESS: The new tests are run and: > - biblio.biblionumber is detected as an auto-increment column > - generated biblionumbers are consecutive >- Sign off > >Regards >--- > t/db_dependent/TestBuilder.t | 25 ++++++++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t >index 0602912..638d2ef 100644 >--- a/t/db_dependent/TestBuilder.t >+++ b/t/db_dependent/TestBuilder.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 41; >+use Test::More tests => 42; > > use Koha::Database; > >@@ -257,6 +257,29 @@ delete $bookseller->{_fk}; > $bookseller_from_db = $rs_aqbookseller->find($bookseller); > is( $bookseller_from_db->in_storage, 1, 'build with only_fk = 0 stores the entry correctly' ); > >+subtest 'Auto-increment values tests' => sub { >+ >+ plan tests => 2; >+ >+ # Pick a table with AI PK >+ my $source = 'Biblio'; # table >+ my $column = 'biblionumber'; # ai column >+ >+ my $col_info = $schema->source( $source )->column_info( $column ); >+ is( $col_info->{is_auto_increment}, 1, "biblio.biblionumber is detected as autoincrement"); >+ >+ # Create a biblio >+ my $biblio_1 = $builder->build({ source => $source }); >+ # Get the AI value >+ my $ai_value = $biblio_1->{ biblionumber }; >+ # Create a biblio >+ my $biblio_2 = $builder->build({ source => $source }); >+ # Get the next AI value >+ my $next_ai_value = $biblio_2->{ biblionumber }; >+ is( $ai_value + 1, $next_ai_value, "AI values are consecutive"); >+ >+}; >+ > $schema->storage->txn_rollback; > > 1; >-- >2.6.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15159
:
44648
|
44788
|
44910