Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-09-09 16:23:15 -0400
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-10-17 11:47:14 -0400
commit9ea66c0440d1e4f4117c4dd6c9dc90f4bb86a817 (patch)
treee30f2a5546540a650df182cfb1206e0ac12a8898 /test
parent9dd1ae3428d869b774668b638b5a05504c538e62 (diff)
downloadliza-9ea66c0440d1e4f4117c4dd6c9dc90f4bb86a817.tar.gz
liza-9ea66c0440d1e4f4117c4dd6c9dc90f4bb86a817.tar.bz2
liza-9ea66c0440d1e4f4117c4dd6c9dc90f4bb86a817.zip
TokenDao: Lift out nondeterminism (date)
* src/server/daemon/controller.js (getUnixTimestamp): New method. Not ideal, but better than where it was. (_initExportService): Pass to TokenDao constructor. * src/server/token/TokenDao.ts (_getTimestamp): New field. (constructor)[get_timestamp]: New param. (updateToken): Use it. * test/server/token/TokenDaoTest.ts: Provide stub timestamp function.
Diffstat (limited to 'test')
-rw-r--r--test/server/token/TokenDaoTest.ts25
1 files changed, 13 insertions, 12 deletions
diff --git a/test/server/token/TokenDaoTest.ts b/test/server/token/TokenDaoTest.ts
index 707493f..b0b9f31 100644
--- a/test/server/token/TokenDaoTest.ts
+++ b/test/server/token/TokenDaoTest.ts
@@ -39,12 +39,13 @@ describe( 'server.token.TokenDao', () =>
{
it( 'updates token with given data', () =>
{
- const field = 'foo_field';
- const qid = 12345;
- const ns = 'namespace';
- const tok_id = 'tok123';
- const tok_type = 'DONE';
- const data = "some data";
+ const field = 'foo_field';
+ const qid = 12345;
+ const ns = 'namespace';
+ const tok_id = 'tok123';
+ const tok_type = 'DONE';
+ const data = "some data";
+ const timestamp = 12345;
const root = field + '.' + ns;
@@ -54,10 +55,9 @@ describe( 'server.token.TokenDao', () =>
expect( given_data.$set[ `${root}.lastStatus` ].timestamp )
.to.be.greaterThan( 0 );
- // TODO: ts is nondeterministic; pass in
const expected_entry: TokenStatus = {
type: tok_type,
- timestamp: given_data.$set[ `${root}.lastStatus` ].timestamp,
+ timestamp: timestamp,
data: data,
};
@@ -83,7 +83,7 @@ describe( 'server.token.TokenDao', () =>
findOne() {},
};
- return new Sut( coll, field )
+ return new Sut( coll, field, () => timestamp )
.updateToken( qid, ns, tok_id, tok_type, data );
} );
@@ -102,7 +102,8 @@ describe( 'server.token.TokenDao', () =>
};
return expect(
- new Sut( coll, 'foo' ).updateToken( 0, 'ns', 'id', 'DONE', null )
+ new Sut( coll, 'foo', () => 0 )
+ .updateToken( 0, 'ns', 'id', 'DONE', null )
).to.eventually.be.rejectedWith( expected_error );
} );
} );
@@ -206,7 +207,7 @@ describe( 'server.token.TokenDao', () =>
};
return expect(
- new Sut( coll, field ).getToken( qid, ns, tok_id )
+ new Sut( coll, field, () => 0 ).getToken( qid, ns, tok_id )
).to.eventually.deep.equal( expected );
} )
);
@@ -226,7 +227,7 @@ describe( 'server.token.TokenDao', () =>
};
return expect(
- new Sut( coll, 'foo' ).getToken( 0, 'ns', 'id' )
+ new Sut( coll, 'foo', () => 0 ).getToken( 0, 'ns', 'id' )
).to.eventually.be.rejectedWith( expected_error );
} );
} );