Skip to content

[test-improver] Improve tests for auth - #14960

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
test-improver/auth-apikey-tests-a2eba6997f66614d
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
test-improver/auth-apikey-tests-a2eba6997f66614d

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

File: internal/auth/apikey_test.go

Changes

  • Merged three overlapping format and length tests (IsValidHex, IsLowercaseHex, LengthConsistency) into one table-style TestGenerateRandomAgentID_Format with t.Run subtests.
  • It uses assert.Regexp instead of regexp.MatchString plus assert.True.
  • The uniqueness test now uses assert.NotContains on a map[string]struct{}.

Coverage: internal/auth was 96.8% before and is 96.8% after. The only uncovered line is the unreachable parse-error branch in ExtractAgentID, since ParseAuthHeader only errors on an empty header, which is handled earlier.

Verification: go vet, gofmt -l, and go test -count=3 -cover ./internal/auth/ all pass.

Generated by Test Improver · copilot · auto · 19.6 AIC · ⊞ 8.6K · ◷

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants