From feca8a78a4f863b93eb60e36f5966eafadb7ed23 Mon Sep 17 00:00:00 2001
From: Lari Taskula <lari.taskula@jns.fi>
Date: Mon, 24 Jul 2017 18:30:10 +0300
Subject: [PATCH] Bug 18977: Rollback branch in t/db_dependent/SIP/Message.t

To test:
1. Before applying patch, check the amount of branches in database
2. prove t/db_dependent/SIP/Message.t
3. See that a new branch is stored
4. Apply patch
5. prove t/db_dependent/SIP/Message.t
6. See that a new branch is no longer stored
---
 t/db_dependent/SIP/Message.t | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t
index 0c1ebcc..e738405 100755
--- a/t/db_dependent/SIP/Message.t
+++ b/t/db_dependent/SIP/Message.t
@@ -54,15 +54,12 @@ my $mockILS = Test::MockObject->new;
 $mockILS->mock( 'check_inst_id', sub {} );
 $mockILS->mock( 'institution_id', sub { $branchcode; } );
 $mockILS->mock( 'find_patron', sub { $findpatron; } );
-$branch = $builder->build({
-    source => 'Branch',
-});
-$branchcode = $branch->{branchcode};
 
 # START testing
 subtest 'Testing Patron Status Request V2' => sub {
     $schema->storage->txn_begin;
     plan tests => 13;
+    $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
     $C4::SIP::Sip::protocol_version = 2;
     test_request_patron_status_v2();
     $schema->storage->txn_rollback;
@@ -71,6 +68,7 @@ subtest 'Testing Patron Status Request V2' => sub {
 subtest 'Testing Patron Info Request V2' => sub {
     $schema->storage->txn_begin;
     plan tests => 18;
+    $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
     $C4::SIP::Sip::protocol_version = 2;
     test_request_patron_info_v2();
     $schema->storage->txn_rollback;
-- 
2.7.4