[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

@@ -15,8 +15,8 @@ require('chai').should()
const modulePath = require('path').join(__dirname, '../../../app/js/UrlFetcher')
const { EventEmitter } = require('events')
describe('UrlFetcher', function() {
beforeEach(function() {
describe('UrlFetcher', function () {
beforeEach(function () {
this.callback = sinon.stub()
this.url = 'https://www.example.com/file/here?query=string'
return (this.UrlFetcher = SandboxedModule.require(modulePath, {
@@ -33,34 +33,34 @@ describe('UrlFetcher', function() {
}
}))
})
describe('pipeUrlToFileWithRetry', function() {
this.beforeEach(function() {
describe('pipeUrlToFileWithRetry', function () {
this.beforeEach(function () {
this.UrlFetcher.pipeUrlToFile = sinon.stub()
})
it('should call pipeUrlToFile', function(done) {
it('should call pipeUrlToFile', function (done) {
this.UrlFetcher.pipeUrlToFile.callsArgWith(2)
this.UrlFetcher.pipeUrlToFileWithRetry(this.url, this.path, err => {
this.UrlFetcher.pipeUrlToFileWithRetry(this.url, this.path, (err) => {
expect(err).to.equal(undefined)
this.UrlFetcher.pipeUrlToFile.called.should.equal(true)
done()
})
})
it('should call pipeUrlToFile multiple times on error', function(done) {
it('should call pipeUrlToFile multiple times on error', function (done) {
const error = new Error("couldn't download file")
this.UrlFetcher.pipeUrlToFile.callsArgWith(2, error)
this.UrlFetcher.pipeUrlToFileWithRetry(this.url, this.path, err => {
this.UrlFetcher.pipeUrlToFileWithRetry(this.url, this.path, (err) => {
expect(err).to.equal(error)
this.UrlFetcher.pipeUrlToFile.callCount.should.equal(3)
done()
})
})
it('should call pipeUrlToFile twice if only 1 error', function(done) {
it('should call pipeUrlToFile twice if only 1 error', function (done) {
this.UrlFetcher.pipeUrlToFile.onCall(0).callsArgWith(2, 'error')
this.UrlFetcher.pipeUrlToFile.onCall(1).callsArgWith(2)
this.UrlFetcher.pipeUrlToFileWithRetry(this.url, this.path, err => {
this.UrlFetcher.pipeUrlToFileWithRetry(this.url, this.path, (err) => {
expect(err).to.equal(undefined)
this.UrlFetcher.pipeUrlToFile.callCount.should.equal(2)
done()
@@ -68,13 +68,13 @@ describe('UrlFetcher', function() {
})
})
describe('pipeUrlToFile', function() {
it('should turn off the cookie jar in request', function() {
describe('pipeUrlToFile', function () {
it('should turn off the cookie jar in request', function () {
return this.defaults.calledWith({ jar: false }).should.equal(true)
})
describe('rewrite url domain if filestoreDomainOveride is set', function() {
beforeEach(function() {
describe('rewrite url domain if filestoreDomainOveride is set', function () {
beforeEach(function () {
this.path = '/path/to/file/on/disk'
this.request.get = sinon
.stub()
@@ -88,7 +88,7 @@ describe('UrlFetcher', function() {
return (this.fs.unlink = (file, callback) => callback())
})
it('should use the normal domain when override not set', function(done) {
it('should use the normal domain when override not set', function (done) {
this.UrlFetcher.pipeUrlToFile(this.url, this.path, () => {
this.request.get.args[0][0].url.should.equal(this.url)
return done()
@@ -99,7 +99,7 @@ describe('UrlFetcher', function() {
return this.fileStream.emit('finish')
})
return it('should use override domain when filestoreDomainOveride is set', function(done) {
return it('should use override domain when filestoreDomainOveride is set', function (done) {
this.settings.filestoreDomainOveride = '192.11.11.11'
this.UrlFetcher.pipeUrlToFile(this.url, this.path, () => {
this.request.get.args[0][0].url.should.equal(
@@ -114,8 +114,8 @@ describe('UrlFetcher', function() {
})
})
return describe('pipeUrlToFile', function() {
beforeEach(function(done) {
return describe('pipeUrlToFile', function () {
beforeEach(function (done) {
this.path = '/path/to/file/on/disk'
this.request.get = sinon
.stub()
@@ -130,8 +130,8 @@ describe('UrlFetcher', function() {
return done()
})
describe('successfully', function() {
beforeEach(function(done) {
describe('successfully', function () {
beforeEach(function (done) {
this.UrlFetcher.pipeUrlToFile(this.url, this.path, () => {
this.callback()
return done()
@@ -142,32 +142,32 @@ describe('UrlFetcher', function() {
return this.fileStream.emit('finish')
})
it('should request the URL', function() {
it('should request the URL', function () {
return this.request.get
.calledWith(sinon.match({ url: this.url }))
.should.equal(true)
})
it('should open the file for writing', function() {
it('should open the file for writing', function () {
return this.fs.createWriteStream
.calledWith(this.path)
.should.equal(true)
})
it('should pipe the URL to the file', function() {
it('should pipe the URL to the file', function () {
return this.urlStream.pipe
.calledWith(this.fileStream)
.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('with non success status code', function() {
beforeEach(function(done) {
this.UrlFetcher.pipeUrlToFile(this.url, this.path, err => {
describe('with non success status code', function () {
beforeEach(function (done) {
this.UrlFetcher.pipeUrlToFile(this.url, this.path, (err) => {
this.callback(err)
return done()
})
@@ -176,7 +176,7 @@ describe('UrlFetcher', function() {
return this.urlStream.emit('end')
})
it('should call the callback with an error', function() {
it('should call the callback with an error', function () {
this.callback.calledWith(sinon.match(Error)).should.equal(true)
const message = this.callback.args[0][0].message
@@ -186,9 +186,9 @@ describe('UrlFetcher', function() {
})
})
return describe('with error', function() {
beforeEach(function(done) {
this.UrlFetcher.pipeUrlToFile(this.url, this.path, err => {
return describe('with error', function () {
beforeEach(function (done) {
this.UrlFetcher.pipeUrlToFile(this.url, this.path, (err) => {
this.callback(err)
return done()
})
@@ -198,11 +198,11 @@ describe('UrlFetcher', function() {
)
})
it('should call the callback with the error', function() {
it('should call the callback with the error', function () {
return this.callback.calledWith(this.error).should.equal(true)
})
return it('should only call the callback once, even if end is called', function() {
return it('should only call the callback once, even if end is called', function () {
this.urlStream.emit('end')
return this.callback.calledOnce.should.equal(true)
})