MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_PublicAPI_ClassifyPAT

Function TestSpec_PublicAPI_ClassifyPAT

pkg/stringutil/spec_test.go:673–708  ·  view source on GitHub ↗

TestSpec_PublicAPI_ClassifyPAT validates the documented behavior of ClassifyPAT as described in the package README.md. Specification: "Determines the token type from its prefix." Prefixes per spec: - github_pat_ → PATTypeFineGrained - ghp_ → PATTypeClassic - gho_ → PATTypeOAuth - (ot

(t *testing.T)

Source from the content-addressed store, hash-verified

671// - gho_ → PATTypeOAuth
672// - (other) → PATTypeUnknown
673func TestSpec_PublicAPI_ClassifyPAT(t *testing.T) {
674 tests := []struct {
675 name string
676 token string
677 expected PATType
678 }{
679 {
680 name: "github_pat_ prefix yields fine-grained",
681 token: "github_pat_abc123",
682 expected: PATTypeFineGrained,
683 },
684 {
685 name: "ghp_ prefix yields classic",
686 token: "ghp_abc123",
687 expected: PATTypeClassic,
688 },
689 {
690 name: "gho_ prefix yields oauth",
691 token: "gho_abc123",
692 expected: PATTypeOAuth,
693 },
694 {
695 name: "unknown prefix yields unknown",
696 token: "xyz_unknown_token",
697 expected: PATTypeUnknown,
698 },
699 }
700
701 for _, tt := range tests {
702 t.Run(tt.name, func(t *testing.T) {
703 result := ClassifyPAT(tt.token)
704 assert.Equal(t, tt.expected, result,
705 "ClassifyPAT(%q) should classify token by prefix", tt.token)
706 })
707 }
708}
709
710// TestSpec_PublicAPI_ValidateCopilotPAT validates the documented behavior of
711// ValidateCopilotPAT as described in the package README.md.

Callers

nothing calls this directly

Calls 2

ClassifyPATFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected