Skip to content

Commit

Permalink
Merge pull request #57 from shopgate/CLOUDSDK-105
Browse files Browse the repository at this point in the history
updated dependencies & fixed unit tests
  • Loading branch information
Daniel Huth authored Dec 12, 2017
2 parents 3563d63 + b28cead commit f3ea201
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
34 changes: 21 additions & 13 deletions lib/actions/BackendAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,27 @@ class BackendAction {
this.pipelines[file].id = pipeline.pipeline.id

let retries = 5
async.whilst(() => retries > 0, (wcb) => {
setTimeout(() => {
this.dcClient.uploadPipeline(pipeline, AppSettings.getInstance().getId(), file.includes(AppSettings.TRUSTED_PIPELINES_FOLDER), (err) => {
if (!err) {
retries = 0
return wcb()
}
logger.debug(err)
if (err.statusCode === 400 || err.code === 'STEP_NOT_FOUND' || retries <= 1) return wcb(err)
wcb()
})
}, 100 * Math.pow(2, 5 - retries--))
}, cb)
let lastError
async.whilst(
() => retries > 0,
(wcb) => {
setTimeout(() => {
this.dcClient.uploadPipeline(pipeline, AppSettings.getInstance().getId(), file.includes(AppSettings.TRUSTED_PIPELINES_FOLDER), (err) => {
lastError = err
if (err) {
logger.debug(err)
if (err.statusCode === 400 || err.code === 'STEP_NOT_FOUND' || retries <= 1) {
return wcb(err)
}
} else {
retries = 0
}
wcb()
})
}, 100 * Math.pow(2, 5 - retries--))
},
(err) => cb(err || lastError)
)
})
}

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"chokidar": "^1.7.0",
"commander": "^2.12.2",
"errio": "^1.2.2",
"fs-extra": "^4.0.2",
"fs-extra": "^5.0.0",
"glob": "^7.1.2",
"inquirer": "^4.0.1",
"morgan": "^1.9.0",
Expand All @@ -67,16 +67,16 @@
},
"devDependencies": {
"coveralls": "^3.0.0",
"lint-staged": "^5.0.0",
"lint-staged": "^6.0.0",
"mocha": "^4.0.1",
"mock-stdin": "^0.3.1",
"nock": "^9.1.3",
"nock": "^9.1.4",
"nsp": "^3.1.0",
"nyc": "^11.4.0",
"portfinder": "^1.0.13",
"pre-commit": "^1.2.2",
"proxyquire": "^1.8.0",
"sinon": "^4.1.2",
"sinon": "^4.1.3",
"socket.io": "^2.0.4",
"standard": "^10.0.3"
},
Expand Down
18 changes: 6 additions & 12 deletions test/actions/BackendAction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,14 @@ describe('BackendAction', () => {
backendAction.backendProcess = new BackendProcess()

backendAction.extensionConfigWatcher = {
start: () => { return backendAction.extensionConfigWatcher },
stop: (cb) => { cb() },
on: (name, cb) => { cb() }
}
backendAction.themeConfigWatcher = {
start: () => { return backendAction.themeConfigWatcher },
stop: (cb) => { cb() },
on: (name, cb) => { cb() }
start: (cb) => cb(),
stop: (cb) => cb(),
on: (name, fn) => fn()
}

backendAction.dcClient.downloadPipelines = (appId, trusted, cb) => cb(null, [{pipeline: {id: 'testPipeline'}}])
backendAction.dcClient.removePipeline = (pId, aId, cb) => cb()
backendAction._extensionChanged = (cfg, cb = () => {}) => {}
backendAction._themeChanged = (cfg, cb = () => {}) => {}
backendAction.dcClient.removePipeline = (pId, aId, trusted, cb) => cb()
backendAction._extensionChanged = (cfg, cb = () => {}) => cb()

try {
backendAction._startSubProcess()
Expand Down Expand Up @@ -216,7 +210,7 @@ describe('BackendAction', () => {
done()
})
})
}).timeout(5000)
})

it('should return if pipeline was changed', (done) => {
const pipeline = {pipeline: {id: 'plFooBarline3'}}
Expand Down
2 changes: 1 addition & 1 deletion test/actions/InitAction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('InitAction', () => {
process.env.APP_PATH = appPath
const appSettings = new AppSettings()
fsEx.emptyDirSync(path.join(appPath, AppSettings.SETTINGS_FOLDER))
appSettings.setId(appId).save().init()
appSettings.setId(appId).setAttachedExtensions({}).save().init()
AppSettings.setInstance(appSettings)

const init = new InitAction()
Expand Down

0 comments on commit f3ea201

Please sign in to comment.