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
5 changes: 5 additions & 0 deletions bin/gstack-question-log
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ eval "$("$SCRIPT_DIR/gstack-slug" 2>/dev/null)"
GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}"
mkdir -p "$GSTACK_HOME/projects/$SLUG"

if [ "$#" -ne 1 ]; then
echo "gstack-question-log: expected one JSON payload argument" >&2
exit 1
fi

INPUT="$1"

# Validate and enrich from registry.
Expand Down
12 changes: 11 additions & 1 deletion test/gstack-question-log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ afterEach(() => {
});

function run(payload: string): { stdout: string; stderr: string; status: number } {
const res = spawnSync(BIN, [payload], {
return runArgs([payload]);
}

function runArgs(args: string[]): { stdout: string; stderr: string; status: number } {
const res = spawnSync(BIN, args, {
env: { ...process.env, GSTACK_HOME: tmpHome },
encoding: 'utf-8',
cwd: ROOT,
Expand Down Expand Up @@ -139,6 +143,12 @@ describe('gstack-question-log — valid payloads', () => {
});

describe('gstack-question-log — rejected payloads', () => {
test('missing payload is rejected with a clear usage error', () => {
const r = runArgs([]);
expect(r.status).not.toBe(0);
expect(r.stderr).toContain('expected one JSON payload argument');
});

test('invalid JSON is rejected', () => {
const r = run('{not-json');
expect(r.status).not.toBe(0);
Expand Down
Loading