MCPcopy Index your code
hub / github.com/google/go-github / TestProjectsV2_Org

Function TestProjectsV2_Org

test/integration/projects_test.go:33–73  ·  view source on GitHub ↗

Integration tests for Projects V2 endpoints defined in github/projects.go. These tests are intentionally defensive. They only require minimal environment variables identifying a target org and user. Project numbers are discovered dynamically by first listing projects and selecting one. For item CRU

(t *testing.T)

Source from the content-addressed store, hash-verified

31// GITHUB_TEST_REPO (repo name)
32
33func TestProjectsV2_Org(t *testing.T) {
34 skipIfMissingAuth(t)
35 org := os.Getenv("GITHUB_TEST_ORG")
36 if org == "" {
37 t.Skip("GITHUB_TEST_ORG not set")
38 }
39
40 ctx := t.Context()
41
42 opts := &github.ListProjectsOptions{}
43 // List projects for org; pick the first available project we can read.
44 projects, _, err := client.Projects.ListOrganizationProjects(ctx, org, opts)
45 if err != nil {
46 // If listing itself fails, abort this test.
47 t.Fatalf("Projects.ListOrganizationProjects returned error: %v", err)
48 }
49 if len(projects) == 0 {
50 t.Skipf("no Projects V2 found for org %s", org)
51 }
52 project := projects[0]
53 if project.Number == nil {
54 t.Skip("selected org project has nil Number field")
55 }
56 projectNumber := *project.Number
57
58 // Re-fetch via Get to exercise endpoint explicitly.
59 proj, _, err := client.Projects.GetOrganizationProject(ctx, org, projectNumber)
60 if err != nil {
61 // Permission mismatch? Skip CRUD while still reporting failure would make the test fail;
62 // we want correctness so treat as fatal here.
63 t.Fatalf("Projects.GetOrganizationProject returned error: %v", err)
64 }
65 if proj.Number == nil || *proj.Number != projectNumber {
66 t.Fatalf("GetOrganizationProject returned unexpected project number: got %+v want %d", proj.Number, projectNumber)
67 }
68
69 _, _, err = client.Projects.ListOrganizationProjectFields(ctx, org, projectNumber, nil)
70 if err != nil {
71 t.Fatalf("Projects.ListOrganizationProjectFields returned error: %v. Fields listing might require extra permissions", err)
72 }
73}
74
75func TestProjectsV2_User(t *testing.T) {
76 skipIfMissingAuth(t)

Callers

nothing calls this directly

Calls 4

skipIfMissingAuthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…