Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitzm@lovullo.com>2017-02-16 16:53:43 -0500
committerMike Gerwitz <gerwitzm@lovullo.com>2017-02-17 11:31:32 -0500
commitac7ec6c5f2f1aa6eec58667dd8de09c4ea2099f2 (patch)
treebbec5b3d981a6f3250cbf419e73cd01cd72d14f3 /test
parenteefd268abf976d85343d44fa30972caecde40122 (diff)
downloadliza-ac7ec6c5f2f1aa6eec58667dd8de09c4ea2099f2.tar.gz
liza-ac7ec6c5f2f1aa6eec58667dd8de09c4ea2099f2.tar.bz2
liza-ac7ec6c5f2f1aa6eec58667dd8de09c4ea2099f2.zip
DataValidator: Hold concurrent requests
Since we maintain state (as a kluge for the time being to integrate with the rest of the system), we need to be careful to protect against concurrent requests that might mess with it before the original request is complete. * src/validate/DataValidator.js (validate, updateFailures): Hold concurrent requests. (_onceReady): Add method. * test/validate/DataValidatorTest.js: Add tests.
Diffstat (limited to 'test')
-rw-r--r--test/validate/DataValidatorTest.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/validate/DataValidatorTest.js b/test/validate/DataValidatorTest.js
index e209a13..ed9a932 100644
--- a/test/validate/DataValidatorTest.js
+++ b/test/validate/DataValidatorTest.js
@@ -316,6 +316,42 @@ describe( 'DataValidator', () =>
);
} );
} );
+
+
+ it( 'queues concurrent requests', () =>
+ {
+ const { sut, vmonitor, getStore } = createStubs( {
+ vmonitor: sinon.createStubInstance( ValidStateMonitor ),
+ } );
+ const { bstore } = getStore();
+
+ const faila = {};
+ const failb = {};
+
+ let running_first = true;
+
+ vmonitor.update = ( _, fail ) =>
+ {
+ if ( fail === failb )
+ {
+ if ( running_first === true )
+ {
+ return Promise.reject( Error(
+ "Request not queued"
+ ) );
+ }
+ }
+
+ return Promise.resolve( true );
+ };
+
+ return Promise.all( [
+ sut.updateFailures( {}, faila )
+ .then( () => running_first = false ),
+
+ sut.updateFailures( {}, failb ),
+ ] );
+ } );
} );