refactor: inject k8s.Runner for testable orchestration (#25)#31
Merged
Conversation
Extract k8s.Runner interface from k8s.Client. Orchestration functions (deployRemote, teardownK8s, ensureCreds, newRemote) now accept Runner instead of constructing clients internally. Add k8s.MockRunner — records calls with prefix-matched responses and errors. Enables unit testing orchestration without a live cluster. Add teardown_test.go with 2 tests: - TestTeardownK8s_NamespaceNotFound: skips all deletes - TestTeardownK8s_FullCleanup: verifies helm uninstall, CRD/SCC/ secret/namespace deletes, gateway cleanup in correct order Validated: unit 82+7, bats 29+29, Go+podman 19/19. Closes #25. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
10 new tests using MockRunner: deployRemote (5 tests): - Success: verifies namespace, CRD, RBAC, Helm, rollout, Route in order - Helm failure: stops before rollout - CRD failure: stops before Helm - No apps domain: returns error - deployLocal with no gateway: returns error ensureCreds (5 tests): - Namespace not found: returns error - Secrets already exist: no creation attempted - Force mode: deletes both secrets - Atlassian created: when JIRA_URL set - Atlassian skipped: when JIRA_URL empty Total: 92 Go harness + 7 launcher + 29 bats = 128 tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extract
k8s.Runnerinterface andMockRunnerfor testable orchestration. All injectable functions now have tests. Closes #25.Changes
k8s.Runnerinterface — mirrors all 11 methods onk8s.Client. Orchestration functions acceptRunnerinstead of constructing clients internally. Variables renamed:nsRunner(namespaced) andclusterRunner(cluster-scoped).k8s.MockRunner— records calls, returns prefix-matched responses/errors. IncludesHasCall,CallCounthelpers.Tests added (12 new)
teardownK8sdeployRemoteensureCredsdeployLocalTest results
128 total tests (was 83 at session start).
Closes #25.