-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration-tests: new test for http adaptor
- Loading branch information
1 parent
0d3b3eb
commit c07d7d3
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,6 +259,43 @@ test('run a job with initial state (no top level keys)', (t) => { | |
}); | ||
}); | ||
|
||
test('run a http adaptor job', (t) => { | ||
return new Promise(async (done) => { | ||
const attempt = { | ||
id: crypto.randomUUID(), | ||
jobs: [ | ||
{ | ||
adaptor: '@openfn/[email protected]', | ||
body: 'get("https://jsonplaceholder.typicode.com/todos/1");', | ||
}, | ||
], | ||
}; | ||
|
||
initLightning(); | ||
|
||
lightning.on('attempt:complete', () => { | ||
const result = lightning.getResult(attempt.id); | ||
|
||
t.truthy(result.response); | ||
t.is(result.response.status, 200); | ||
t.truthy(result.response.headers); | ||
|
||
t.deepEqual(result.data, { | ||
userId: 1, | ||
id: 1, | ||
title: 'delectus aut autem', | ||
completed: false, | ||
}); | ||
|
||
done(); | ||
}); | ||
|
||
await initWorker(); | ||
|
||
lightning.enqueueAttempt(attempt); | ||
}); | ||
}); | ||
|
||
// TODO this sort of works but the server side of it does not | ||
// Will work on it more | ||
// TODO2: the runtime doesn't return config anymore (correctly!) | ||
|