Skip to content

[test] Cover presentation helper output#293

Open
ibobgunardi wants to merge 1 commit into
lugassawan:mainfrom
ibobgunardi:bobi/cover-presentation-helpers
Open

[test] Cover presentation helper output#293
ibobgunardi wants to merge 1 commit into
lugassawan:mainfrom
ibobgunardi:bobi/cover-presentation-helpers

Conversation

@ibobgunardi

Copy link
Copy Markdown
Contributor

Closes #273.

Adds direct output tests for:

  • printWorktreeResult copied, missing, and symlink-skipped rows
  • printSyncDryRun merge dry-run output

Checks:

  • gofmt -w cmd/add_test.go cmd/sync_test.go
  • git diff --check

Note: I could not run go test locally because this host has Go 1.25.1 while go.mod requires Go 1.26.4, and automatic toolchain switching hung in the sandbox.

Comment thread cmd/add_test.go

func TestPrintWorktreeResultCopySkipBranches(t *testing.T) {
cmd, buf := newTestCmd()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium — Test name TestPrintWorktreeResultCopySkipBranches is misleading.

The suffix Branches does not describe what is tested. The test covers Copied, Skipped, and SkippedSymlinks output lines — no branch-plural concept is involved. A reader scanning test names builds a wrong mental model.

Suggested fix: Rename to TestPrintWorktreeResultCopyAndSkipped or TestPrintWorktreeResultAllFields.

Comment thread cmd/sync_test.go
if got := buf.String(); got != want {
t.Fatalf("output = %q, want %q", got, want)
}
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium — The push=false branch of printSyncDryRun is not tested.

The guard if push { ... } (in cmd/sync.go) is the only conditional branch in the function, yet this test covers only push=true. A regression that unconditionally prints the push line would not be caught.

Suggested fix: Add a second test case, e.g.:

func TestPrintSyncDryRunRebaseNoPush(t *testing.T) {
    cmd, buf := newTestCmd()
    printSyncDryRun(cmd, "feature/login", "main", false, false)
    got := buf.String()
    if !strings.Contains(got, "would rebase") {
        t.Fatalf("expected rebase verb, got: %q", got)
    }
    if strings.Contains(got, "would push") {
        t.Fatalf("push line must be absent, got: %q", got)
    }
}

Comment thread cmd/add_test.go
func TestPrintWorktreeResultCopySkipBranches(t *testing.T) {
cmd, buf := newTestCmd()

printWorktreeResult(cmd, "Created worktree", operations.AddResult{

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low — The empty-fields path of printWorktreeResult is not tested.

The three len > 0 guards (for Copied, Skipped, SkippedSymlinks) are untested with the current test. A complementary test would verify those lines are correctly suppressed when the slices are nil.

Suggested fix: Add TestPrintWorktreeResultMinimal with an AddResult where all slice fields are nil, and assert the output contains only the header, Branch, and Path lines (and does NOT contain "Copied:", "Skipped", or "symlinks").

lugassawan

This comment was marked as duplicate.

@lugassawan lugassawan dismissed their stale review June 10, 2026 09:11

Changing to comment — findings need addressing before approval.

@lugassawan lugassawan left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Decision: COMMENT


Reviewed by reviewer (swe-workbench). Posted 3 inline comments, deduped 0.

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.

[chore] Cover presentation helpers printWorktreeResult / printSyncDryRun

2 participants