Skip to content

test: raise pkg/aws coverage to 31.4% + fix ListInstances nil panic - #5

Merged
scttfrdmn merged 1 commit into
mainfrom
test/raise-pkg-aws-coverage
May 30, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
test/raise-pkg-aws-coverage

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

First coverage pass on spawn's highest-leverage package (#3), plus a nil-panic fix found via the new tests.

Coverage

Package Before After
pkg/aws 13.6% 31.4%
aggregate 24.7% 25.7%

CI ratchet floor raised 22 → 24. (spawn is a 40+ package module, so doubling pkg/aws moves the aggregate modestly — more passes to come per #3.)

What's tested

Pure helpers (no AWS): DetectArchitecture, estimateVolumeSize, buildBlockDevices (default / size override / hibernate-RAM-sizing / KMS encryption), valueOrEmpty, contains/findSubstring, and the IAM helpers generateRoleName (determinism + uniqueness), hashPolicies, buildInlinePolicy (template + spored base + unknown-template skip), buildIAMTags.

Lifecycle via substrate: GetInstanceState, UpdateInstanceTags, Terminate, StopInstance/StartInstance, GetInstancePublicIP, ListInstances (with/without state filter), key-pair import+check, GetAccountID, GetEnabledRegions, Config/GetConfig.

Bug fix

listInstancesInRegion dereferenced instance.State.Name and instance.Placement.AvailabilityZone unconditionally. Both are pointers AWS may leave nil — so ListInstances panicked on any instance missing placement or state (surfaced immediately by the substrate test). Now both are nil-guarded.

Verification

go build, go vet, gofmt, golangci-lint (changed files clean), go test ./pkg/aws/ pass. Gate validated: 25.7% ≥ 24%.

…ic (#3)

pkg/aws helper tests (no AWS): DetectArchitecture, estimateVolumeSize,
buildBlockDevices (default/override/hibernate/KMS), valueOrEmpty, contains/
findSubstring, and the IAM pure helpers (generateRoleName determinism,
hashPolicies, buildInlinePolicy, buildIAMTags).

pkg/aws lifecycle tests via substrate: GetInstanceState, UpdateInstanceTags,
Terminate, Stop/Start, GetInstancePublicIP, ListInstances, key-pair ops,
GetAccountID, GetEnabledRegions, Config/GetConfig accessors.

Fixes a nil-pointer panic in listInstancesInRegion: instance.State and
instance.Placement are pointers AWS may leave nil, but the code dereferenced
them unconditionally — ListInstances would crash on any instance missing
placement/state. Now guarded.

Aggregate spawn coverage 24.7% → 25.7%. CI ratchet floor raised 22 → 24.
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.

1 participant