[misc] bump the dev-env to 3.3.2

This commit is contained in:
Jakob Ackermann
2020-08-10 17:01:11 +01:00
parent 1ee48d0274
commit f4561c2fe2
66 changed files with 1371 additions and 1458 deletions

View File

@@ -16,8 +16,8 @@ require('chai').should()
const modulePath = require('path').join(__dirname, '../../../app/js/UrlCache')
const { EventEmitter } = require('events')
describe('UrlCache', function() {
beforeEach(function() {
describe('UrlCache', function () {
beforeEach(function () {
this.callback = sinon.stub()
this.url = 'www.example.com/file'
this.project_id = 'project-id-123'
@@ -34,16 +34,16 @@ describe('UrlCache', function() {
}))
})
describe('_doesUrlNeedDownloading', function() {
beforeEach(function() {
describe('_doesUrlNeedDownloading', function () {
beforeEach(function () {
this.lastModified = new Date()
return (this.lastModifiedRoundedToSeconds = new Date(
Math.floor(this.lastModified.getTime() / 1000) * 1000
))
})
describe('when URL does not exist in cache', function() {
beforeEach(function() {
describe('when URL does not exist in cache', function () {
beforeEach(function () {
this.UrlCache._findUrlDetails = sinon.stub().callsArgWith(2, null, null)
return this.UrlCache._doesUrlNeedDownloading(
this.project_id,
@@ -53,21 +53,21 @@ describe('UrlCache', function() {
)
})
return it('should return the callback with true', function() {
return it('should return the callback with true', function () {
return this.callback.calledWith(null, true).should.equal(true)
})
})
return describe('when URL does exist in cache', function() {
beforeEach(function() {
return describe('when URL does exist in cache', function () {
beforeEach(function () {
this.urlDetails = {}
return (this.UrlCache._findUrlDetails = sinon
.stub()
.callsArgWith(2, null, this.urlDetails))
})
describe('when the modified date is more recent than the cached modified date', function() {
beforeEach(function() {
describe('when the modified date is more recent than the cached modified date', function () {
beforeEach(function () {
this.urlDetails.lastModified = new Date(
this.lastModified.getTime() - 1000
)
@@ -79,19 +79,19 @@ describe('UrlCache', function() {
)
})
it('should get the url details', function() {
it('should get the url details', function () {
return this.UrlCache._findUrlDetails
.calledWith(this.project_id, this.url)
.should.equal(true)
})
return it('should return the callback with true', function() {
return it('should return the callback with true', function () {
return this.callback.calledWith(null, true).should.equal(true)
})
})
describe('when the cached modified date is more recent than the modified date', function() {
beforeEach(function() {
describe('when the cached modified date is more recent than the modified date', function () {
beforeEach(function () {
this.urlDetails.lastModified = new Date(
this.lastModified.getTime() + 1000
)
@@ -103,13 +103,13 @@ describe('UrlCache', function() {
)
})
return it('should return the callback with false', function() {
return it('should return the callback with false', function () {
return this.callback.calledWith(null, false).should.equal(true)
})
})
describe('when the cached modified date is equal to the modified date', function() {
beforeEach(function() {
describe('when the cached modified date is equal to the modified date', function () {
beforeEach(function () {
this.urlDetails.lastModified = this.lastModified
return this.UrlCache._doesUrlNeedDownloading(
this.project_id,
@@ -119,13 +119,13 @@ describe('UrlCache', function() {
)
})
return it('should return the callback with false', function() {
return it('should return the callback with false', function () {
return this.callback.calledWith(null, false).should.equal(true)
})
})
describe('when the provided modified date does not exist', function() {
beforeEach(function() {
describe('when the provided modified date does not exist', function () {
beforeEach(function () {
this.lastModified = null
return this.UrlCache._doesUrlNeedDownloading(
this.project_id,
@@ -135,13 +135,13 @@ describe('UrlCache', function() {
)
})
return it('should return the callback with true', function() {
return it('should return the callback with true', function () {
return this.callback.calledWith(null, true).should.equal(true)
})
})
return describe('when the URL does not have a modified date', function() {
beforeEach(function() {
return describe('when the URL does not have a modified date', function () {
beforeEach(function () {
this.urlDetails.lastModified = null
return this.UrlCache._doesUrlNeedDownloading(
this.project_id,
@@ -151,23 +151,23 @@ describe('UrlCache', function() {
)
})
return it('should return the callback with true', function() {
return it('should return the callback with true', function () {
return this.callback.calledWith(null, true).should.equal(true)
})
})
})
})
describe('_ensureUrlIsInCache', function() {
beforeEach(function() {
describe('_ensureUrlIsInCache', function () {
beforeEach(function () {
this.UrlFetcher.pipeUrlToFileWithRetry = sinon.stub().callsArg(2)
return (this.UrlCache._updateOrCreateUrlDetails = sinon
.stub()
.callsArg(3))
})
describe('when the URL needs updating', function() {
beforeEach(function() {
describe('when the URL needs updating', function () {
beforeEach(function () {
this.UrlCache._doesUrlNeedDownloading = sinon
.stub()
.callsArgWith(3, null, true)
@@ -179,7 +179,7 @@ describe('UrlCache', function() {
)
})
it('should check that the url needs downloading', function() {
it('should check that the url needs downloading', function () {
return this.UrlCache._doesUrlNeedDownloading
.calledWith(
this.project_id,
@@ -189,7 +189,7 @@ describe('UrlCache', function() {
.should.equal(true)
})
it('should download the URL to the cache file', function() {
it('should download the URL to the cache file', function () {
return this.UrlFetcher.pipeUrlToFileWithRetry
.calledWith(
this.url,
@@ -198,7 +198,7 @@ describe('UrlCache', function() {
.should.equal(true)
})
it('should update the database entry', function() {
it('should update the database entry', function () {
return this.UrlCache._updateOrCreateUrlDetails
.calledWith(
this.project_id,
@@ -208,7 +208,7 @@ describe('UrlCache', function() {
.should.equal(true)
})
return it('should return the callback with the cache file path', function() {
return it('should return the callback with the cache file path', function () {
return this.callback
.calledWith(
null,
@@ -218,8 +218,8 @@ describe('UrlCache', function() {
})
})
return describe('when the URL does not need updating', function() {
beforeEach(function() {
return describe('when the URL does not need updating', function () {
beforeEach(function () {
this.UrlCache._doesUrlNeedDownloading = sinon
.stub()
.callsArgWith(3, null, false)
@@ -231,11 +231,11 @@ describe('UrlCache', function() {
)
})
it('should not download the URL to the cache file', function() {
it('should not download the URL to the cache file', function () {
return this.UrlFetcher.pipeUrlToFileWithRetry.called.should.equal(false)
})
return it('should return the callback with the cache file path', function() {
return it('should return the callback with the cache file path', function () {
return this.callback
.calledWith(
null,
@@ -246,8 +246,8 @@ describe('UrlCache', function() {
})
})
describe('downloadUrlToFile', function() {
beforeEach(function() {
describe('downloadUrlToFile', function () {
beforeEach(function () {
this.cachePath = 'path/to/cached/url'
this.destPath = 'path/to/destination'
this.UrlCache._copyFile = sinon.stub().callsArg(2)
@@ -263,25 +263,25 @@ describe('UrlCache', function() {
)
})
it('should ensure the URL is downloaded and updated in the cache', function() {
it('should ensure the URL is downloaded and updated in the cache', function () {
return this.UrlCache._ensureUrlIsInCache
.calledWith(this.project_id, this.url, this.lastModified)
.should.equal(true)
})
it('should copy the file to the new location', function() {
it('should copy the file to the new location', function () {
return this.UrlCache._copyFile
.calledWith(this.cachePath, this.destPath)
.should.equal(true)
})
return it('should call the callback', function() {
return it('should call the callback', function () {
return this.callback.called.should.equal(true)
})
})
describe('_deleteUrlCacheFromDisk', function() {
beforeEach(function() {
describe('_deleteUrlCacheFromDisk', function () {
beforeEach(function () {
this.fs.unlink = sinon.stub().callsArg(1)
return this.UrlCache._deleteUrlCacheFromDisk(
this.project_id,
@@ -290,7 +290,7 @@ describe('UrlCache', function() {
)
})
it('should delete the cache file', function() {
it('should delete the cache file', function () {
return this.fs.unlink
.calledWith(
this.UrlCache._cacheFilePathForUrl(this.project_id, this.url)
@@ -298,13 +298,13 @@ describe('UrlCache', function() {
.should.equal(true)
})
return it('should call the callback', function() {
return it('should call the callback', function () {
return this.callback.called.should.equal(true)
})
})
describe('_clearUrlFromCache', function() {
beforeEach(function() {
describe('_clearUrlFromCache', function () {
beforeEach(function () {
this.UrlCache._deleteUrlCacheFromDisk = sinon.stub().callsArg(2)
this.UrlCache._clearUrlDetails = sinon.stub().callsArg(2)
return this.UrlCache._clearUrlFromCache(
@@ -314,25 +314,25 @@ describe('UrlCache', function() {
)
})
it('should delete the file on disk', function() {
it('should delete the file on disk', function () {
return this.UrlCache._deleteUrlCacheFromDisk
.calledWith(this.project_id, this.url)
.should.equal(true)
})
it('should clear the entry in the database', function() {
it('should clear the entry in the database', function () {
return this.UrlCache._clearUrlDetails
.calledWith(this.project_id, this.url)
.should.equal(true)
})
return it('should call the callback', function() {
return it('should call the callback', function () {
return this.callback.called.should.equal(true)
})
})
return describe('clearProject', function() {
beforeEach(function() {
return describe('clearProject', function () {
beforeEach(function () {
this.urls = ['www.example.com/file1', 'www.example.com/file2']
this.UrlCache._findAllUrlsInProject = sinon
.stub()
@@ -341,15 +341,15 @@ describe('UrlCache', function() {
return this.UrlCache.clearProject(this.project_id, this.callback)
})
it('should clear the cache for each url in the project', function() {
return Array.from(this.urls).map(url =>
it('should clear the cache for each url in the project', function () {
return Array.from(this.urls).map((url) =>
this.UrlCache._clearUrlFromCache
.calledWith(this.project_id, url)
.should.equal(true)
)
})
return it('should call the callback', function() {
return it('should call the callback', function () {
return this.callback.called.should.equal(true)
})
})