(t *testing.T)
| 75 | } |
| 76 | |
| 77 | func TestValidateCopilotPAT(t *testing.T) { |
| 78 | tests := []struct { |
| 79 | name string |
| 80 | token string |
| 81 | expectError bool |
| 82 | errorMsg string |
| 83 | }{ |
| 84 | { |
| 85 | name: "valid fine-grained PAT", |
| 86 | token: "github_pat_abc123xyz", |
| 87 | expectError: false, |
| 88 | }, |
| 89 | { |
| 90 | name: "classic PAT should fail", |
| 91 | token: "ghp_abc123xyz", |
| 92 | expectError: true, |
| 93 | errorMsg: "classic personal access tokens", |
| 94 | }, |
| 95 | { |
| 96 | name: "OAuth token should fail", |
| 97 | token: "gho_abc123xyz", |
| 98 | expectError: true, |
| 99 | errorMsg: "OAuth tokens", |
| 100 | }, |
| 101 | { |
| 102 | name: "unknown token should fail", |
| 103 | token: "random_token", |
| 104 | expectError: true, |
| 105 | errorMsg: "unrecognized token format", |
| 106 | }, |
| 107 | { |
| 108 | name: "empty token should fail", |
| 109 | token: "", |
| 110 | expectError: true, |
| 111 | errorMsg: "unrecognized token format", |
| 112 | }, |
| 113 | } |
| 114 | |
| 115 | for _, tt := range tests { |
| 116 | t.Run(tt.name, func(t *testing.T) { |
| 117 | err := ValidateCopilotPAT(tt.token) |
| 118 | if tt.expectError { |
| 119 | require.Error(t, err, "should return error for invalid token") |
| 120 | assert.Contains(t, err.Error(), tt.errorMsg, "error message should contain expected text") |
| 121 | } else { |
| 122 | assert.NoError(t, err, "should not return error for valid token") |
| 123 | } |
| 124 | }) |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | func TestGetPATTypeDescription(t *testing.T) { |
| 129 | tests := []struct { |
nothing calls this directly
no test coverage detected