test: add unit tests for core packages (P1+P2)#14
Merged
Conversation
Add 101 unit tests across 5 packages that previously had zero test coverage: - pkg/names: format validation, word list integrity, variety, no duplicates - pkg/config: Load() with defaults/missing/invalid/overrides, validate() branches (PAT vs App auth, owner, webhook secret gen), duration parsers, Logger levels/formats, VM config TOML parsing - pkg/github: verifySignature (7 cases), isSelfHosted, isTrackedRepo, IsOrgLevel, parseEphemerdImage (YAML parsing + explicit job names), base64url, WebhookHandler (method filtering, sig verification, event filtering, repo filtering, malformed payloads, nil fields) - pkg/scheduler: New() defaults/custom/edge, buildLabelsForOS, isLinuxJob, canHandleJob (platform + dispatch), isConflict (GitHub ErrorResponse, wrapped, string fallback), cleanSeen TTL expiry, handleHealthz JSON - pkg/networking: subnetInUse (invalid/empty/loopback/valid CIDRs), pickSubnet (valid CIDR, prefers default, determinism), DefaultSubnet Also fixes pre-existing issues: - Fix go:embed failure on Windows by adding EnsurePlaceholders() to mage/download that creates empty ephemerd-linux placeholder when the cross-compiled binary doesn't exist - Move Config.subnet() to subnet_linux.go (only called from linux code) to fix unused function lint errors on Windows/macOS - Fix 7 errcheck violations in network_windows.go and linuxvm_windows.go - Remove unused wslOutput() function from linuxvm_windows.go
luthermonson
added a commit
that referenced
this pull request
Apr 28, 2026
Adds three groups of unit tests around scheduler invariants the existing suite did not exercise: - backoffDuration repo-level state: a simulated provider event sequence (failure/success/failure) that asserts resetBackoff returns the next failure to the 2s base; a 60s cap stress test running 50 iterations; and an interleaved multi-repo test guarding against accidental shared state in the failureCounts map. - Concurrent claim + dedup (item #13): 32 goroutines call handleQueued for the same job id at the same time; only one ClaimJob and one dispatch CreateJob fire. A companion test verifies that two providers both claiming the SAME numeric job id each get exactly one claim (composite-key routing). - Timeout / cancellation during cleanup (item #14): handleCompleted invoked with a cancelled parent ctx still calls dispatch.Destroy via context.Background; destroyAll destroys every dispatched container even when the parent ctx is cancelled; handleLinuxJob whose Wait errors triggers a Destroy on the cleanup path; destroyAll Stops every macosVM exactly once. Tests use an in-process gRPC dispatch fake (TCP loopback) plus a counting provider mock so no external systems are touched.
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
pkg/names,pkg/config,pkg/github,pkg/scheduler,pkg/networkinggo:embedfailure that brokego test,go vet, and linting on Windows (missingephemerd-linuxplaceholder)What's tested
pkg/namespkg/configpkg/githubpkg/schedulerpkg/networkingLint/build fixes
mage/download:EnsurePlaceholders()creates emptyephemerd-linuxforgo:embedon Windowspkg/networking: movedConfig.subnet()tosubnet_linux.go(unused on Windows/macOS)pkg/networking: fixed 5 uncheckedDelete()/NamespaceDetach()calls innetwork_windows.gopkg/vm: fixed 2 uncheckedClose()calls, removed unusedwslOutput()inlinuxvm_windows.goTest plan
mage cipasses (lint + test + build)go test ./...passes with 0 failures🤖 Generated with Claude Code