@@ -247,8 +247,6 @@ describe('objectPut API', () => {
247247 } ) ;
248248 } ) ;
249249
250- const formatTime = time => time . slice ( 0 , 20 ) ;
251-
252250 const testObjectLockConfigs = [
253251 {
254252 testMode : 'COMPLIANCE' ,
@@ -261,8 +259,8 @@ describe('objectPut API', () => {
261259 type : 'Years' ,
262260 } ,
263261 ] ;
264- testObjectLockConfigs . forEach ( config => {
265- const { testMode, type, val } = config ;
262+ testObjectLockConfigs . forEach ( lockConfig => {
263+ const { testMode, type, val } = lockConfig ;
266264 it ( 'should put an object with default retention if object does not ' +
267265 'have retention configuration but bucket has' , done => {
268266 const testPutObjectRequest = new DummyRequest ( {
@@ -288,17 +286,18 @@ describe('objectPut API', () => {
288286 assert . strictEqual ( headers . ETag , `"${ correctMD5 } "` ) ;
289287 metadata . getObjectMD ( bucketName , objectName , { } ,
290288 log , ( err , md ) => {
291- const mode = md . retentionMode ;
292- const retainDate = md . retentionDate ;
293- const date = moment ( ) ;
294- const days
295- = type === 'Days' ? val : val * 365 ;
296- const expectedDate
297- = date . add ( days , 'days' ) ;
298289 assert . ifError ( err ) ;
290+
291+ const mode = md . retentionMode ;
299292 assert . strictEqual ( mode , testMode ) ;
300- assert . strictEqual ( formatTime ( retainDate ) ,
301- formatTime ( expectedDate . toISOString ( ) ) ) ;
293+
294+ const retainDate = moment ( md . retentionDate ) ;
295+ const days = type === 'Days' ? val : val * 365 ;
296+ const { scaledMsPerDay } = config . getTimeOptions ( ) ;
297+ const date = moment ( ) . add ( days * scaledMsPerDay , 'ms' ) ;
298+ const dateDiff = retainDate . diff ( date , 'ms' ) ;
299+ assert . ok ( dateDiff < 10 ) ;
300+
302301 done ( ) ;
303302 } ) ;
304303 } ) ;
@@ -307,7 +306,6 @@ describe('objectPut API', () => {
307306 } ) ;
308307 } ) ;
309308
310-
311309 it ( 'should successfully put an object with legal hold ON' , done => {
312310 const request = new DummyRequest ( {
313311 bucketName,
@@ -413,8 +411,7 @@ describe('objectPut API', () => {
413411 } , postBody ) ;
414412
415413 bucketPut ( authInfo , testPutBucketRequest , log , ( ) => {
416- const config = require ( '../../../lib/Config' ) ;
417- config . config . testingMode = true ;
414+ config . testingMode = true ;
418415 objectPut ( authInfo , testPutObjectRequest , undefined , log ,
419416 ( err , resHeaders ) => {
420417 assert . strictEqual ( resHeaders . ETag , `"${ correctMD5 } "` ) ;
@@ -430,7 +427,7 @@ describe('objectPut API', () => {
430427 // The header should be removed after being treated.
431428 assert ( md [ lastModifiedHeader ] === undefined ) ;
432429
433- config . config . testingMode = false ;
430+ config . testingMode = false ;
434431 done ( ) ;
435432 } ) ;
436433 } ) ;
@@ -452,8 +449,7 @@ describe('objectPut API', () => {
452449 } , postBody ) ;
453450
454451 bucketPut ( authInfo , testPutBucketRequest , log , ( ) => {
455- const config = require ( '../../../lib/Config' ) ;
456- config . config . testingMode = false ;
452+ config . testingMode = false ;
457453 objectPut ( authInfo , testPutObjectRequest , undefined , log ,
458454 ( err , resHeaders ) => {
459455 assert . strictEqual ( resHeaders . ETag , `"${ correctMD5 } "` ) ;
0 commit comments