Skip to content

Commit

Permalink
fix: detect plugin getSetting method when present (#14077)
Browse files Browse the repository at this point in the history
* fix: detect plugin getSetting method when present

* Add getSettings to vm test expects

---------

Co-authored-by: Harry Waye <[email protected]>
  • Loading branch information
2 people authored and raquelmsmith committed Feb 4, 2023
1 parent a7724d4 commit ba9085c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions plugin-server/src/worker/vm/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export function createPluginConfigVM(
onEvent: __asyncFunctionGuard(__bindMeta('onEvent'), 'onEvent'),
onSnapshot: __asyncFunctionGuard(__bindMeta('onSnapshot'), 'onSnapshot'),
processEvent: __asyncFunctionGuard(__bindMeta('processEvent'), 'processEvent'),
getSettings: __bindMeta('getSettings'),
};
const __tasks = {
Expand Down
4 changes: 2 additions & 2 deletions plugin-server/tests/worker/capabilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('capabilities', () => {
export function randomFunction (event, meta) { return event}
export function onEvent (event, meta) { return event }
export function onSnapshot (event, meta) { return event }
export function getSettings (meta) { return { handlesLargeBatches: true } }
export function runEveryHour(meta) {console.log('1')}
export const jobs = {
Expand All @@ -62,7 +62,7 @@ describe('capabilities', () => {
expect(capabilities).toEqual({
jobs: ['x'],
scheduled_tasks: ['runEveryHour'],
methods: ['onEvent', 'onSnapshot', 'processEvent'],
methods: ['onEvent', 'onSnapshot', 'processEvent', 'getSettings'],
})
})
})
Expand Down
1 change: 1 addition & 0 deletions plugin-server/tests/worker/plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('plugins', () => {
const vm = await pluginConfig.vm!.resolveInternalVm
expect(Object.keys(vm!.methods).sort()).toEqual([
'exportEvents',
'getSettings',
'onEvent',
'onSnapshot',
'processEvent',
Expand Down
1 change: 1 addition & 0 deletions plugin-server/tests/worker/vm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('vm tests', () => {
expect(Object.keys(vm).sort()).toEqual(['methods', 'tasks', 'vm', 'vmResponseVariable'])
expect(Object.keys(vm.methods).sort()).toEqual([
'exportEvents',
'getSettings',
'onEvent',
'onSnapshot',
'processEvent',
Expand Down

0 comments on commit ba9085c

Please sign in to comment.