test(storage): drive providers/storage + minio to ≥95% coverage#143
Merged
Conversation
Adds external + internal tests for the storage facade and the MinIO admin
backend so both subpackages clear the 95% gate.
- providers/storage: 66.7% → 99.0%
- providers/storage/minio: 0.0% → 95.9%
Tests cover:
- DeriveStorageMode truth table (all 4 permutations)
- decideStorageMode-equivalent capability fan-out via Capabilities()
- Provider facade nil-receiver safety on every accessor
- NewFromConfig across DO Spaces / R2 / S3 / MinIO + unknown backend
- backendForStorageProvider switch arms (R2 / S3 / MinIO / default)
- tagForStorageProvider switch arms (r2 / s3 / minio / default)
- Provision wrap-error path + StorageMode label on credentials
- Deprovision legacy+canonical candidate probing + soft-error path
- customerEndpointURL all six publicURL/endpoint/TLS permutations
- MinIO New: missing endpoint / missing creds / whitespace trim /
default-bucket / MinIORootUser fallback / madmin client build error
- MinIO IssueTenantCredentials: happy path, prefix trim, empty-prefix
fallback, empty-bucket fallback, AddUser/AddCannedPolicy/SetPolicy
rollback paths (idempotent cleanup)
- MinIO RevokeTenantCredentials: empty-keyID no-op, happy path,
soft-error swallowing on stale identifiers, raw-id (no key_ prefix)
- MinIO buildPolicy IAM shape (cross-tenant isolation contract pin)
- Factory registration via init() side effect
The two remaining uncovered lines in minio.IssueTenantCredentials are
defensive error paths around crypto/rand and json.Marshal of a static
struct — practically unreachable under normal conditions.
Co-Authored-By: Claude Opus 4.7 (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
internal/providers/storage: 66.7% → 99.0%internal/providers/storage/minio: 0.0% → 95.9%Adds external + internal tests for the storage facade and MinIO admin backend so both subpackages clear the 95% gate. Coverage includes DeriveStorageMode truth table, Provider nil-safety, NewFromConfig across all backends, backendForStorageProvider / tagForStorageProvider switch arms, Provision wrap-error + StorageMode label, Deprovision legacy + canonical candidate probing, customerEndpointURL permutations, and the full MinIO Issue/Revoke happy + rollback paths via httptest mock admin.
The two remaining uncovered lines in
minio.IssueTenantCredentialsare defensive error paths aroundcrypto/rand.Readandjson.Marshalof a static struct — practically unreachable.Test plan
go test ./internal/providers/storage/... -count=1 -timeout 120s→ all PASSgo test ./internal/providers/storage/ -coverprofile=...→ 99.0%go test ./internal/providers/storage/minio/ -coverprofile=...→ 95.9%go build ./...cleango vet ./internal/providers/storage/...cleanCo-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com