Skip to content

Commit 7316625

Browse files
Jake ChampionJakeChampion
authored andcommitted
add more tests for error conditions in the cli
1 parent 342f9fa commit 7316625

5 files changed

+93
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import test from 'brittle';
2+
import { getBinPath } from 'get-bin-path'
3+
import { prepareEnvironment } from '@gmrchk/cli-testing-library';
4+
5+
const cli = await getBinPath()
6+
7+
test('should return non-zero exit code', async function (t) {
8+
const { execute, cleanup, makeDir, writeFile, path} = await prepareEnvironment();
9+
t.teardown(async function () {
10+
await cleanup();
11+
});
12+
await makeDir('./engine.wasm')
13+
await writeFile('./bin/index.js', `addEventListener('fetch', function(){})`)
14+
const { code, stdout, stderr } = await execute('node', `${cli} --engine-wasm ${path}/engine.wasm`);
15+
16+
t.alike(stdout, []);
17+
t.alike(stderr, ['Error: The `wasmEngine` path does not point to a file: {{base}}/engine.wasm']);
18+
t.is(code, 1);
19+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import test from 'brittle';
2+
import { getBinPath } from 'get-bin-path'
3+
import { prepareEnvironment } from '@gmrchk/cli-testing-library';
4+
5+
const cli = await getBinPath()
6+
7+
test('should return non-zero exit code', async function (t) {
8+
const { execute, cleanup, makeDir} = await prepareEnvironment();
9+
t.teardown(async function () {
10+
await cleanup();
11+
});
12+
await makeDir('./bin/index.js')
13+
const { code, stdout, stderr } = await execute('node', cli);
14+
15+
t.alike(stdout, []);
16+
t.alike(stderr, ['Error: The `input` path does not point to a file: {{base}}/bin/index.js']);
17+
t.is(code, 1);
18+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import test from 'brittle';
2+
import { getBinPath } from 'get-bin-path'
3+
import { prepareEnvironment } from '@gmrchk/cli-testing-library';
4+
5+
const cli = await getBinPath()
6+
7+
test('should return non-zero exit code', async function (t) {
8+
const { execute, cleanup, writeFile,path} = await prepareEnvironment();
9+
t.teardown(async function () {
10+
await cleanup();
11+
});
12+
13+
await writeFile('./bin/index.js', `addEventListener('fetch', function(){})`)
14+
const { code, stdout, stderr } = await execute('node', `${cli} --engine-wasm ${path}/engine.wasm`);
15+
16+
t.alike(stdout, []);
17+
t.alike(stderr, ['Error: The `wasmEngine` path points to a non-existant file: {{base}}/engine.wasm']);
18+
t.is(code, 1);
19+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import test from 'brittle';
2+
import { getBinPath } from 'get-bin-path'
3+
import { prepareEnvironment } from '@gmrchk/cli-testing-library';
4+
5+
const cli = await getBinPath()
6+
7+
test('should return non-zero exit code', async function (t) {
8+
const { execute, cleanup} = await prepareEnvironment();
9+
t.teardown(async function () {
10+
await cleanup();
11+
});
12+
13+
const { code, stdout, stderr } = await execute('node', cli);
14+
15+
t.alike(stdout, []);
16+
t.alike(stderr, ['Error: The `input` path points to a non-existant file: {{base}}/bin/index.js']);
17+
t.is(code, 1);
18+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import test from 'brittle';
2+
import { getBinPath } from 'get-bin-path'
3+
import { prepareEnvironment } from '@gmrchk/cli-testing-library';
4+
5+
const cli = await getBinPath()
6+
7+
test('should return non-zero exit code', async function (t) {
8+
const { execute, cleanup, makeDir, writeFile} = await prepareEnvironment();
9+
t.teardown(async function () {
10+
await cleanup();
11+
});
12+
await makeDir('./bin/main.wasm')
13+
await writeFile('./bin/index.js', `addEventListener('fetch', function(){})`)
14+
const { code, stdout, stderr } = await execute('node', cli);
15+
16+
t.alike(stdout, []);
17+
t.alike(stderr, ['Error: The `output` path does not point to a file: {{base}}/bin/main.wasm']);
18+
t.is(code, 1);
19+
});

0 commit comments

Comments
 (0)