Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions integration-tests/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @openfn/integration-tests-cli

## 1.0.7

### Patch Changes

- Updated dependencies [4cc799b]
- Updated dependencies [4cc799b]
- Updated dependencies [3e63c08]
- Updated dependencies [4cc799b]
- Updated dependencies [6689ad0]
- @openfn/lightning-mock@2.4.0
- @openfn/project@0.10.0

## 1.0.6

### Patch Changes
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-cli",
"private": true,
"version": "1.0.6",
"version": "1.0.7",
"description": "CLI integration tests",
"author": "Open Function Group <admin@openfn.org>",
"license": "ISC",
Expand All @@ -16,6 +16,7 @@
},
"dependencies": {
"@openfn/lightning-mock": "workspace:^",
"@openfn/project": "workspace:*",
"@types/node": "^18.19.127",
"ava": "5.3.1",
"date-fns": "^2.30.0",
Expand Down
6 changes: 4 additions & 2 deletions integration-tests/cli/test/deploy.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import test from 'ava';
import run from '../src/run';
import createLightningServer from '@openfn/lightning-mock';
import createLightningServer, {
DEFAULT_PROJECT_ID,
} from '@openfn/lightning-mock';
import { extractLogs, assertLog } from '../src/util';
import { rimraf } from 'rimraf';

Expand All @@ -18,7 +20,7 @@ test.before(async () => {

// This should fail against the built CLI right now
test.serial(
`OPENFN_ENDPOINT=${endpoint} openfn pull 123 --log-json`,
`OPENFN_ENDPOINT=${endpoint} openfn pull ${DEFAULT_PROJECT_ID} --log-json`,
async (t) => {
const { stdout, stderr } = await run(t.title);
t.falsy(stderr);
Expand Down
39 changes: 39 additions & 0 deletions integration-tests/cli/test/execute-workflow.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
import test from 'ava';
import { rm, mkdir } from 'node:fs/promises';
import path from 'node:path';

import createLightningServer from '@openfn/lightning-mock';

import run from '../src/run';
import { getJSON } from '../src/util';

// set up a lightning mock
let server: any;

const port = 8968;

test.before(async () => {
server = await createLightningServer({ port });
server.collections.createCollection('stuff');
// Important: the collection value MUST be as string
server.collections.upsert('stuff', 'x', JSON.stringify({ id: 'x' }));
});

const jobsPath = path.resolve('test/fixtures');

// Note that these tests are STATEFUL
Expand Down Expand Up @@ -147,6 +162,17 @@ test.serial(
}
);

test.serial(
`openfn ${jobsPath}/wf-creds.json --credentials ${jobsPath}/creds.json`,
async (t) => {
const { err, stdout, stderr } = await run(t.title);
t.falsy(err);

const out = getJSON();
t.is(out.value, 'admin:admin');
}
);

test.serial(
`openfn ${jobsPath}/wf-errors.json -S "{ \\"data\\": { \\"number\\": 2 } }"`,
async (t) => {
Expand Down Expand Up @@ -273,3 +299,16 @@ test.serial(
});
}
);

// collections basic test
test.serial(
`openfn ${jobsPath}/collections.json --endpoint http://localhost:${port} --api-key xyz`,
async (t) => {
const { err } = await run(t.title);
t.falsy(err);

const out = getJSON();

t.deepEqual(out.data, { id: 'x' });
}
);
10 changes: 10 additions & 0 deletions integration-tests/cli/test/fixtures/collections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"workflow": {
"steps": [
{
"adaptor": "common",
"expression": "collections.get('stuff', 'x')"
}
]
}
}
4 changes: 4 additions & 0 deletions integration-tests/cli/test/fixtures/creds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn((s) => {
s.value = `${s.configuration.user}:${s.configuration.password}`;
return s;
});
6 changes: 6 additions & 0 deletions integration-tests/cli/test/fixtures/creds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"08089249-0890-4a73-8799-e2ec2b9e5d77": {
"user": "admin",
"password": "admin"
}
}
11 changes: 11 additions & 0 deletions integration-tests/cli/test/fixtures/wf-creds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"workflow": {
"steps": [
{
"adaptor": "common",
"configuration": "08089249-0890-4a73-8799-e2ec2b9e5d77",
"expression": "creds.js"
}
]
}
}
Loading