Skip to content

Commit

Permalink
Add concurrency to the limits map to allow the client to request conr…
Browse files Browse the repository at this point in the history
…rency limits (#218)
  • Loading branch information
mcdan committed Feb 22, 2021
1 parent 699130f commit 5b313c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ declare namespace openwhisk {
timeout?: number;
memory?: number;
logs?: number;
concurrency?: number;
}

interface Response<T extends Dict> {
Expand Down
20 changes: 20 additions & 0 deletions test/unit/actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,26 @@ test('create a new action with limits', t => {
return actions.create({ name: '12345', action, limits })
})

test('create a new action with concurrency setting', t => {
t.plan(4)
const ns = '_'
const client = {}
const action = 'function main() { // main function body};'
const limits = {
concurrency: 2
}
const actions = new Actions(client)

client.request = (method, path, options) => {
t.is(method, 'PUT')
t.is(path, `namespaces/${ns}/actions/12345`)
t.deepEqual(options.qs, {})
t.deepEqual(options.body, { exec: { kind: 'nodejs:default', code: action }, limits: { concurrency: 2 } })
}

return actions.create({ name: '12345', action, limits })
})

test('create an action without providing an action body', t => {
const actions = new Actions()
t.throws(() => actions.create({ name: '12345' }), /Missing mandatory action/)
Expand Down

0 comments on commit 5b313c1

Please sign in to comment.