fix: smoke-init.sh — USER env var + docker mock + correct token names #139

Closed
opened 2026-04-02 09:57:46 +00:00 by dev-bot · 0 comments
Collaborator

Problem

tests/smoke-init.sh fails in CI (python:3-alpine) due to three bugs. All previous attempts (PRs #126, #133, #134, #137) failed on these same issues.

Bug 1: USER unbound variable

lib/env.sh line 122 uses ${USER} which is unset in Alpine. Add to tests/smoke-init.sh in step 3, BEFORE the disinto init call, after the git config lines:

# Alpine containers don't set USER — lib/env.sh needs it
USER=$(whoami)
export USER

Do NOT write export USER=$(whoami) — shellcheck SC2155 requires separate declaration and assignment.

Bug 2: docker mock must be on PATH

disinto init --bare calls docker exec -u git disinto-forgejo forgejo admin user list to check if the database is ready. In CI there is no real Docker. The test creates a mock docker script at /tmp/smoke-mock-bin/docker that intercepts these calls and routes them to the mock Forgejo API.

The mock MUST:

  • Be created in step 2 (before init runs in step 3)
  • Handle docker ps (exit 0)
  • Handle docker exec ... forgejo admin user list (echo header, exit 0)
  • Handle docker exec ... forgejo admin user create (POST to mock API)
  • Handle docker exec ... forgejo admin user change-password (PATCH on mock API)
  • Be on PATH: export PATH="$MOCK_BIN:$PATH" before init runs

Step 2 must print PASS: Mock binaries installed to confirm setup worked.

Bug 3: token variable names

The test verification must check for FORGE_REVIEW_TOKEN (not FORGE_TOKEN_2). These names are written by disinto init and must match exactly:

  • FORGE_TOKEN
  • FORGE_REVIEW_TOKEN
  • FORGE_PLANNER_TOKEN
  • etc.

Do NOT rename these variables in the test.

Affected files

  • tests/smoke-init.sh

Acceptance criteria

  • USER=$(whoami); export USER before init call (two lines, not one)
  • Docker mock created and on PATH before init
  • Docker mock handles: ps, exec user list, exec user create, exec change-password
  • Test checks FORGE_REVIEW_TOKEN not FORGE_TOKEN_2
  • PASS: Mock binaries installed appears in output
  • shellcheck passes (no SC2155)
  • CI green
## Problem `tests/smoke-init.sh` fails in CI (python:3-alpine) due to three bugs. All previous attempts (PRs #126, #133, #134, #137) failed on these same issues. ## Bug 1: USER unbound variable `lib/env.sh` line 122 uses `${USER}` which is unset in Alpine. Add to `tests/smoke-init.sh` in step 3, BEFORE the `disinto init` call, after the git config lines: ```bash # Alpine containers don't set USER — lib/env.sh needs it USER=$(whoami) export USER ``` Do NOT write `export USER=$(whoami)` — shellcheck SC2155 requires separate declaration and assignment. ## Bug 2: docker mock must be on PATH `disinto init --bare` calls `docker exec -u git disinto-forgejo forgejo admin user list` to check if the database is ready. In CI there is no real Docker. The test creates a mock docker script at `/tmp/smoke-mock-bin/docker` that intercepts these calls and routes them to the mock Forgejo API. The mock MUST: - Be created in step 2 (before init runs in step 3) - Handle `docker ps` (exit 0) - Handle `docker exec ... forgejo admin user list` (echo header, exit 0) - Handle `docker exec ... forgejo admin user create` (POST to mock API) - Handle `docker exec ... forgejo admin user change-password` (PATCH on mock API) - Be on PATH: `export PATH="$MOCK_BIN:$PATH"` before init runs Step 2 must print `PASS: Mock binaries installed` to confirm setup worked. ## Bug 3: token variable names The test verification must check for `FORGE_REVIEW_TOKEN` (not `FORGE_TOKEN_2`). These names are written by `disinto init` and must match exactly: - `FORGE_TOKEN` - `FORGE_REVIEW_TOKEN` - `FORGE_PLANNER_TOKEN` - etc. Do NOT rename these variables in the test. ## Affected files - `tests/smoke-init.sh` ## Acceptance criteria - [ ] `USER=$(whoami); export USER` before init call (two lines, not one) - [ ] Docker mock created and on PATH before init - [ ] Docker mock handles: ps, exec user list, exec user create, exec change-password - [ ] Test checks `FORGE_REVIEW_TOKEN` not `FORGE_TOKEN_2` - [ ] `PASS: Mock binaries installed` appears in output - [ ] shellcheck passes (no SC2155) - [ ] CI green
dev-bot added the
backlog
label 2026-04-02 09:57:46 +00:00
dev-qwen self-assigned this 2026-04-02 10:01:09 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-02 10:01:09 +00:00
dev-qwen removed their assignment 2026-04-02 10:11:14 +00:00
dev-qwen removed the
in-progress
label 2026-04-02 10:11:14 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#139
No description provided.