Skip to content

Increase test coverage from 29.6% to 78.8% (target: 70%) - #10

Draft
zparnold with Copilot wants to merge 2 commits into
mainfrom
copilot/increase-test-coverage-to-70
Draft

Increase test coverage from 29.6% to 78.8% (target: 70%)#10
zparnold with Copilot wants to merge 2 commits into
mainfrom
copilot/increase-test-coverage-to-70

Conversation

Copilot AI commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Test coverage was at 29.6% with no tests for pkg/k8s and sparse coverage in pkg/api and pkg/cleanup. Brings total coverage to 78.8% by introducing fake Kubernetes client injection and comprehensive test suites across all packages.

Core enabler: fake k8s client injection

pkg/k8s/client.go: changed clientset field from *kubernetes.Clientset to kubernetes.Interface (backward-compatible) and added NewClientFromInterface() constructor — allows tests to inject k8s.io/client-go/kubernetes/fake without hitting a real cluster.

New / expanded test coverage

  • pkg/k8s (0% → 80.1%): portToInt32 boundary cases; GetPodStatus for all pod phases including CrashLoopBackOff; CreateSandbox variants (RuntimeClass, ImagePullSecrets, CA cert mount, env vars, all command forms); DeleteSandbox (normal + not-found); WaitForPodReady timeout; DiscoverRuntimeBySessionID/RuntimeID (found, missing, no-label cases)

  • pkg/api (27.2% → 84.8%): Full handler lifecycle via fake k8s — StartRuntime, StopRuntime, PauseRuntime, ResumeRuntime success paths; all error/validation branches; LoggingMiddleware in debug mode; rewriteCookiePath and createProxyResponseRewriter edge cases; VSCode proxy routing

  • pkg/cleanup (21.0% → 87.7%): Start/Stop with context cancellation; runCleanup with failed-pod and idle-pod cleanup; LastActivityTime vs CreatedAt idle threshold logic

  • pkg/types (83.3% → 100%): FlexibleCommand.String() and invalid JSON unmarshal error path

Threshold enforcement

Updated coverage gate from 25% → 70% in both Makefile and .github/workflows/ci.yml.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • runtime-rt-vscode.test.svc.cluster.local
    • Triggering command: /tmp/go-build4041447183/b001/api.test /tmp/go-build4041447183/b001/api.test -test.paniconexit0 -test.gocoverdir=/tmp/go-build4041447183/b001/gocoverdir -test.timeout=10m0s -test.coverprofile=/tmp/go-build4041447183/b001/_cover_.out go1.24.12 -coveragecfg=/tmp/go-build234948492/b001/coveragecfg -c=4 -nolocalimports -importcfg /tmp/go-build234948492/b001/importcfg -pack -o .test -trimpath ux_amd64/compile -p /v1/fake imerchan=1,gotestjsonbuildtext=1-stringintconv ux_amd64/compile (dns block)
    • Triggering command: /tmp/go-build1794031033/b001/api.test /tmp/go-build1794031033/b001/api.test -test.paniconexit0 -test.gocoverdir=/tmp/go-build1794031033/b001/gocoverdir -test.timeout=10m0s -test.coverprofile=/tmp/go-build1794031033/b001/_cover_.out d/rbac/v1/fake/dINVALID,NEW d/rbac/v1/fake/f-j ux_amd64/compileDROP -p github.com/golan-test.paniconexit0 -lang=go1.17 ux_amd64/compile-test.timeout=10m0s -uns�� 48687320/b612/gocoverdir /tmp/go-build1848687320/b028/vet-nolocalimports -data-downloader -c=4 fake -importcfg -data-downloader (dns block)
    • Triggering command: /tmp/go-build185634227/b659/api.test /tmp/go-build185634227/b659/api.test -test.paniconexit0 -test.gocoverdir=/tmp/go-build185634227/b659/gocoverdir -test.timeout=10m0s -test.coverprofile=/tmp/go-build185634227/b659/_cover_.out 8687320/b527/_pkg_.a -trimpath (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: zparnold <5190984+zparnold@users.noreply.github.com>
Copilot AI changed the title [WIP] Increase test coverage to 70 percent Increase test coverage from 29.6% to 78.8% (target: 70%) Feb 24, 2026
Copilot AI requested a review from zparnold February 24, 2026 14:42
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