Skip to content

Commit

Permalink
worker: tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
josephjclark committed Mar 4, 2024
1 parent ebd495c commit 968e879
Showing 1 changed file with 36 additions and 38 deletions.
74 changes: 36 additions & 38 deletions packages/ws-worker/test/worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import test from 'ava';
import createRTE from '@openfn/engine-multi';
import createLogger, { createMockLogger } from '@openfn/logger';
import { createMockLogger } from '@openfn/logger';

import type { ExitReason } from '@openfn/lexicon/lightning';

Expand Down Expand Up @@ -30,13 +30,6 @@ test.before(async () => {
engine = await createRTE({
maxWorkers: 1,
logger,
// autoinstall: {
// handleIsInstalled: async () => false,
// handleInstall: () =>
// new Promise((_resolve, reject) => {
// setTimeout(() => reject(new Error('not the way to amarillo')), 1);
// }),
// },
});
});

Expand All @@ -49,8 +42,8 @@ const execute = async (plan: ExecutionPlan, input = {}, options = {}) =>
const channel = mockChannel({
[RUN_START]: async () => true,
[STEP_START]: async () => true,
[RUN_LOG]: async (evt) => {
console.log(evt.source, evt.message)
[RUN_LOG]: async (_evt) => {
//console.log(evt.source, evt.message)
return true
},
[STEP_COMPLETE]: async () => true,
Expand All @@ -70,33 +63,38 @@ const execute = async (plan: ExecutionPlan, input = {}, options = {}) =>

// Repro for https://github.com/OpenFn/kit/issues/616
// This will not run in CI unless the env is set
if (process.env.OPENFN_TEST_SF_TOKEN && process.env.OPENFN_TEST_SF_PASSWORD)
test('salesforce issue', async (t) => {
const plan = createPlan({
expression: `bulk(
'Contact',
'insert',
{
failOnError: true,
allowNoOp: true,
},
state => ([{
"name": "testy mctestface",
"email": "[email protected]"
}])
)`,
adaptor: '@openfn/[email protected]',
configuration: {
username: '[email protected]',
securityToken: process.env.OPENFN_TEST_SF_TOKEN,
password: process.env.OPENFN_TEST_SF_PASSWORD,
loginUrl: 'https://login.salesforce.com',
}
});
if (process.env.OPENFN_TEST_SF_TOKEN && process.env.OPENFN_TEST_SF_PASSWORD) {
// hard skipping the test because the insert actually fails (permissions)
test.skip('salesforce issue', async (t) => {
const plan = createPlan({
id: 'x',
expression: `bulk(
'Contact',
'insert',
{
failOnError: true,
allowNoOp: true,
},
state => ([{
"name": "testy mctestface",
"email": "[email protected]"
}])
)`,
adaptor: '@openfn/[email protected]',
configuration: {
username: '[email protected]',
securityToken: process.env.OPENFN_TEST_SF_TOKEN,
password: process.env.OPENFN_TEST_SF_PASSWORD,
loginUrl: 'https://login.salesforce.com',
}
});

const input = { data: { result: 42 } };

const input = { data: { result: 42 } };
const result= await execute(plan, input);
t.log(result)

const result= await execute(plan, input);
t.log(result)
t.is(result.reason.reason, 'success');
})
// Actually this fails right but it's a permissions thing on the sandbox
t.is(result.reason.reason, 'success');
})
}

0 comments on commit 968e879

Please sign in to comment.