Bugzilla – Attachment 100335 Details for
Bug 24817
Fix timing issues in t/db_dependant/Koha/Cash/Register.t
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24817: Add sleep between db create actions
Bug-24817-Add-sleep-between-db-create-actions.patch (text/plain), 3.01 KB, created by
Martin Renvoize (ashimema)
on 2020-03-09 10:39:30 UTC
(
hide
)
Description:
Bug 24817: Add sleep between db create actions
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-03-09 10:39:30 UTC
Size:
3.01 KB
patch
obsolete
>From 79f2230c5dbb867f56f278883c8d527c9944c236 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 6 Mar 2020 08:25:39 +0000 >Subject: [PATCH] Bug 24817: Add sleep between db create actions > >We need to allow some time to pass between calls that add cash register >lines to accountlines or cash_register_actions. We use database level >triggers to maintain the timestamp fields, so cannot use Time::Fake, and >the methods we are testing assume that, as human interactions, there >will be at least a second between the last 'sale' on a cash register and >the 'cashup' of that same cash register. > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Cash/Register.pm | 2 +- > t/db_dependent/Koha/Cash/Register.t | 8 ++++++++ > 2 files changed, 9 insertions(+), 1 deletion(-) > >diff --git a/Koha/Cash/Register.pm b/Koha/Cash/Register.pm >index ac14db6d6c..d033ab6ff2 100644 >--- a/Koha/Cash/Register.pm >+++ b/Koha/Cash/Register.pm >@@ -126,7 +126,7 @@ sub outstanding_accountlines { > > my $local_conditions = > $since->count >- ? { 'timestamp' => { '>=' => $since->get_column('timestamp')->as_query } } >+ ? { 'timestamp' => { '>' => $since->get_column('timestamp')->as_query } } > : {}; > my $merged_conditions = > $conditions >diff --git a/t/db_dependent/Koha/Cash/Register.t b/t/db_dependent/Koha/Cash/Register.t >index dbac2b2bac..e24fb06f1d 100644 >--- a/t/db_dependent/Koha/Cash/Register.t >+++ b/t/db_dependent/Koha/Cash/Register.t >@@ -203,6 +203,11 @@ subtest 'cashup' => sub { > subtest 'outstanding_accountlines' => sub { > plan tests => 4; > >+ # add_cashup should not happen simultaneously with any other action >+ # that results in an accountline attached to the same cash register. >+ # In testing, we need to sleep for a second after each action that >+ # adds to the database. (We cannot use Time::Fake as timestamps are >+ # being added at the DB level, not in perl. > my $accountline1 = $builder->build_object( > { > class => 'Koha::Account::Lines', >@@ -215,12 +220,14 @@ subtest 'cashup' => sub { > value => { register_id => $register->id }, > } > ); >+ sleep 1; > > my $accountlines = $register->outstanding_accountlines; > is( $accountlines->count, 2, 'No cashup, all accountlines returned' ); > > my $cashup3 = > $register->add_cashup( { manager_id => $patron->id, amount => '2.50' } ); >+ sleep 1; > > $accountlines = $register->outstanding_accountlines; > is( $accountlines->count, 0, 'Cashup added, no accountlines returned' ); >@@ -231,6 +238,7 @@ subtest 'cashup' => sub { > value => { register_id => $register->id }, > } > ); >+ sleep 1; > > $accountlines = $register->outstanding_accountlines; > is( $accountlines->count, 1, >-- >2.20.1
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 24817
:
100215
|
100275
|
100303
|
100304
|
100326
|
100327
| 100335 |
100336