MCPcopy Index your code
hub / github.com/git-bug/git-bug / TestValidateProject

Function TestValidateProject

bridge/github/config_test.go:158–226  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

156}
157
158func TestValidateProject(t *testing.T) {
159 envPrivate := os.Getenv("GITHUB_TOKEN_PRIVATE")
160 if envPrivate == "" {
161 t.Skip("Env var GITHUB_TOKEN_PRIVATE missing")
162 }
163
164 envPublic := os.Getenv("GITHUB_TOKEN_PUBLIC")
165 if envPublic == "" {
166 t.Skip("Env var GITHUB_TOKEN_PUBLIC missing")
167 }
168
169 tokenPrivate := auth.NewToken(target, envPrivate)
170 tokenPublic := auth.NewToken(target, envPublic)
171
172 type args struct {
173 owner string
174 project string
175 token *auth.Token
176 }
177 tests := []struct {
178 name string
179 args args
180 want bool
181 }{
182 {
183 name: "public repository and token with scope 'public_repo'",
184 args: args{
185 project: "git-bug",
186 owner: "git-bug",
187 token: tokenPublic,
188 },
189 want: true,
190 },
191 {
192 name: "private repository and token with scope 'repo'",
193 args: args{
194 project: "test-github-bridge",
195 owner: "git-bug",
196 token: tokenPrivate,
197 },
198 want: true,
199 },
200 {
201 name: "private repository and token with scope 'public_repo'",
202 args: args{
203 project: "test-github-bridge",
204 owner: "git-bug",
205 token: tokenPublic,
206 },
207 want: false,
208 },
209 {
210 name: "project not existing",
211 args: args{
212 project: "cant-find-this",
213 owner: "organisation-not-found",
214 token: tokenPublic,
215 },

Callers

nothing calls this directly

Calls 3

NewTokenFunction · 0.92
RunMethod · 0.80
validateProjectFunction · 0.70

Tested by

no test coverage detected