MCPcopy Create free account
hub / github.com/cli/cli / TestNewUploader

Function TestNewUploader

internal/attachments/client_test.go:372–552  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

370}
371
372func TestNewUploader(t *testing.T) {
373 const badTokenErr = "unsupported authentication type"
374 const badPermissionErr = "attaching files requires write access to the repository"
375
376 tests := []struct {
377 name string
378 tokenType gh.TokenType
379 host string
380 targetRepository int64
381 viewerPermission string
382 wantErr string
383 }{
384 {
385 name: "github.com",
386 tokenType: gh.TokenTypeOAuth,
387 host: "github.com",
388 targetRepository: 42,
389 viewerPermission: "WRITE",
390 },
391 {
392 name: "data residency tenant",
393 tokenType: gh.TokenTypeOAuth,
394 host: "acme.ghe.com",
395 targetRepository: 7,
396 viewerPermission: "WRITE",
397 },
398 {
399 name: "classic personal access token",
400 tokenType: gh.TokenTypePersonalAccess,
401 host: "github.com",
402 targetRepository: 42,
403 viewerPermission: "WRITE",
404 },
405 {
406 name: "fine-grained personal access token",
407 tokenType: gh.TokenTypeFineGrainedPAT,
408 host: "github.com",
409 targetRepository: 42,
410 viewerPermission: "WRITE",
411 },
412 {
413 name: "rejects an enterprise server host",
414 tokenType: gh.TokenTypeOAuth,
415 host: "github.example.com",
416 targetRepository: 42,
417 viewerPermission: "WRITE",
418 wantErr: "attaching files is not supported on GitHub Enterprise Server",
419 },
420 {
421 // This row defends a message, not an order. On an enterprise server
422 // the token message would tell the user to re-authenticate, and that
423 // remedy does not work there. The other checks are free to move.
424 name: "reports the host before the token",
425 tokenType: gh.TokenTypeServerToServer,
426 host: "github.example.com",
427 targetRepository: 42,
428 viewerPermission: "WRITE",
429 wantErr: "attaching files is not supported on GitHub Enterprise Server",

Callers

nothing calls this directly

Calls 5

VerifyMethod · 0.95
NewUploaderFunction · 0.85
EqualMethod · 0.80
EmptyMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected