Skip to content

Add integration test harness, push/deploy + TUI tests, document two production bugs#252

Open
l-hellmann wants to merge 25 commits into
mainfrom
cli-tests
Open

Add integration test harness, push/deploy + TUI tests, document two production bugs#252
l-hellmann wants to merge 25 commits into
mainfrom
cli-tests

Conversation

@l-hellmann
Copy link
Copy Markdown
Collaborator

What Type of Change is this?

  • New Feature
  • Fix
  • Improvement
  • Release
  • Other

Description (required)

Builds an in-process integration test harness for zcli commands and adds
unit-level UI tests for the bubbletea models. Includes minimal production-code
seams to enable testing without changing user-facing behavior. Also documents
two confirmed bugs as skipped regression tests (fixes intentionally left for
follow-up PRs to keep this one scoped to test infrastructure).

Production changes (small, backward-compatible)

  • zeropsRestApiClient.NewAuthorizedClient accepts a full URL or a bare host;
    defaults the scheme to https:// when missing.
  • cmdBuilder.RunRootCmd(rootCmd, RunOptions{Ctx, Args, Stdout, Stderr})
    new test-friendly entry point that returns an exit code instead of calling
    os.Exit. ExecuteRootCmd becomes a thin wrapper around it.
  • logger.OutputConfig.Out accepts an io.Writer (defaults to os.Stderr),
    so uxBlock output can be captured.
  • flagParams.New(notice io.Writer) routes "Using config file:" notices
    through the injected stderr.
  • New env var ZEROPS_CLI_YAML_FILE_PATH overrides the per-user .zcli.yml
    location (parity with ZEROPS_CLI_DATA_FILE_PATH and ZEROPS_CLI_LOG_FILE_PATH).
  • Empty ZEROPS_TOKEN env value no longer overrides a token persisted by
    zcli login — previously export ZEROPS_TOKEN= would silently log out.
  • yamlReader.ResetCache() — exported so in-process test re-runs aren't
    served stale bytes from the package-level cache.

New tests

Integration (src/cmd/, //go:build devel, run via make test-integration):

  • Harness with httptest.Server, per-test tempdir, login/scope seeding,
    archive decompression, and git fixture helpers.
  • 14 service-push tests (happy paths, error paths, polling, scope, archive-file-path).
  • 7 git-archive tests (not-init / zero-commits errors, workspace-state
    clean/staged/all, --deploy-git-folder).
  • 1 service-deploy variant.
  • 1 project-list, 1 login, 1 version.

TUI (src/uxBlock/models/, via github.com/charmbracelet/x/exp/teatest):

  • selector (10): single + multi-select, filter-mode, esc, clamping, label.
  • prompt (7): cursor movement, clamping, esc, initial position.
  • input (5): typing, backspace, esc, empty submit, label render.
  • table (11): renderer output, body indexing, deep clone, cell pretty-flag.

Confirmed bugs documented as skipped tests (pushDeploy_bugs_test.go)

  1. --setup flag ignored when the service name happens to match a setup
    name in zerops.yaml (servicePush.go:85, serviceDeploy.go:72).
    Reproduced from a real pipeline running --setup showcase-backend on a
    service named "backend".
  2. SIGSEGV nil-deref on apiProcess.AppVersion.Id / .Build
    (servicePush.go:235, :251) when a process poll returns
    status=RUNNING with appVersion: null. Crashes the binary from the
    spinner goroutine. Confirmed by removing the t.Skip in isolation; stack
    trace is in the test comment.

Both tests are committed as t.Skip'd reproductions so CI stays green;
removing the skip after each fix will lock the regression in.

Test plan

  • make test — unit tests pass.
  • make test-integration — 24 PASS + 2 SKIP, ~16 s.
  • TUI tests pass — 33 across 4 packages, <1 s combined.
  • Branch builds for darwin/arm64, linux/amd64, windows/amd64.
  • make lint reports zero issues in src/ and cmd/ (after running
    tools/install.sh). The lint binary itself reports a pre-existing
    toolchain mismatch in golang.org/x/crypto/.../fips140only_go1.26.go
    when the developer has Go ≥1.26 installed; unrelated to this diff.

Related issues & labels (optional)

l-hellmann added 25 commits May 13, 2026 12:17
…ntext() in TUI tests, checked type assertions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant