Skip to content

test: raise real coverage to 92% and measure every package in CI - #71

Merged
vibecheck-bot merged 4 commits into
mainfrom
test/real-coverage
Oct 7, 2026
Merged

vibecheck-bot merged 4 commits into
mainfrom
test/real-coverage

Conversation

@rshdhere

@rshdhere rshdhere commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Why

The awesome-go review of vibecheck (avelino/awesome-go#5938) was closed because go test -cover ./... reported 35–39% total while the Codecov badge showed 82.96%. The gap had a clear cause: coverage.yaml only measured 7 hand-picked internal/* packages and skipped cmd/ and every LLM provider, which had almost no real tests.

This PR raises the real number and makes Codecov report it honestly.

Result (go test -coverprofile=c.out ./... && go tool cover -func=c.out)

Before After
Total 39.1% 92.1%
cmd 8.8% 91.2%
internal/git 35.7% 100%
internal/llm/ollama 3.7% 92.6%
internal/llm/{deepseek,kimi,qwen} 14–15% 96–97%
internal/llm/{anthropic,grok,groq} 31–44% 100%
internal/llm/{openai,gemini,perplexity} 66–78%* 96–100%

* Those numbers came from tests silently calling the live APIs with whatever keys were in the developer's ~/.vibecheck_keys.json.

Changes

fix(llm): openai, grok and groq indexed Choices[0] without a length check, so an empty response would panic. They now return no response choices from <provider>, like the HTTP clients already did.

test(llm): Every provider is now tested against an httptest server. The tests check request shape, auth headers, model, response parsing and error paths (non-200, bad JSON, empty choices, bad URL, unreachable host). This replaces the old tautological tests (if "x" != "x").

  • Small test seams: apiURL / baseURL package vars on the 6 clients with hardcoded endpoints, and endpointOptions on gemini. openai/anthropic use the SDKs' own OPENAI_BASE_URL / ANTHROPIC_BASE_URL, and ollama uses OLLAMA_HOST. Default behaviour is unchanged.
  • Each test isolates HOME and the provider env vars, so no real keys are read and no network calls go out.

test(cmd):

  • commit runs end to end in a temp git repo with fake providers (GIT_EDITOR=true).
  • keys, models and dashboard are tested at the model level and through RunE with scripted keystrokes. This uses a new teaOptions hook in root.go; the default is empty, so production behaviour is identical.
  • upgrade runs the full download → extract → replace flow against a fake GitHub API with a scratch binary. githubAPIURL is now a var, and there is a new executablePath hook.
  • The previously skipped CommitWMessage test is now real.

ci(github-actions): coverage.yaml now runs go test -race -covermode=atomic -coverprofile=coverage.out ./..., so Codecov matches local go test -cover ./.... The workflow also reads the Go version from go.mod; it had been pinned to 1.22, while the module requires 1.25.

Verification

  • go vet ./... and gofmt -l . are clean
  • go test -race -count=3 ./... passes
  • The full suite passes with HTTP(S)_PROXY pointed at a dead port, which proves no test hits an external API
  • Each commit builds and passes tests on its own

Not covered (intentionally): rerunWithSudo and Execute call os.Exit, and main() is the process entrypoint.

- Guard Choices[0] access in openai, grok and groq clients with a length check
- Return "no response choices from <provider>" instead of panicking with index out of range
- Align behavior with the deepseek, kimi, qwen and perplexity HTTP clients
- Expose apiURL in deepseek, kimi, qwen and perplexity and baseURL in grok and groq as package vars
- Add endpointOptions to the gemini client so tests can target a local REST endpoint
- Drive openai and anthropic tests through OPENAI_BASE_URL and ANTHROPIC_BASE_URL, and ollama through OLLAMA_HOST
- Replace tautological constant checks with tests asserting request shape, auth headers, model and response parsing
- Cover non-200, malformed json, empty choices, invalid url and unreachable server error paths
- Isolate HOME and provider env vars so tests never read real keys or call live APIs
- Add teaOptions to root.go and pass it to every bubbletea program so tests can script input and capture output
- Make githubAPIURL and executablePath vars in upgrade.go to substitute a local server and scratch binary
- Run commit end to end in a temp git repo with fake providers, covering success, notices and error paths
- Test keys, models and dashboard models directly plus via RunE with scripted keystrokes
- Test release fetch, download, tar.gz and zip extraction, binary replacement and the full upgrade flow
- Replace the skipped CommitWMessage test with real ones using GIT_EDITOR to avoid an interactive editor
- Run go test with -coverprofile over ./... instead of a hand-picked subset of internal packages
- Enable -race with atomic cover mode to catch data races in CI
- Read the Go version from go.mod instead of pinning 1.22, which mismatched the 1.25 toolchain
@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@vibecheck-bot vibecheck-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

@vibecheck-bot
vibecheck-bot merged commit 1ce77f0 into main Oct 7, 2026
6 checks passed
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.

2 participants