diff --git a/github/classroom.go b/github/classroom.go new file mode 100644 index 00000000000..8f6ce14511e --- /dev/null +++ b/github/classroom.go @@ -0,0 +1,82 @@ +// Copyright 2025 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" + "net/http" +) + +// ClassroomService handles communication with the GitHub Classroom related +// methods of the GitHub API. +// +// GitHub API docs: https://docs.github.com/rest/classroom/classroom +type ClassroomService service + +// Classroom represents a GitHub Classroom. +type Classroom struct { + ID *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Archived *bool `json:"archived,omitempty"` + Organization *Organization `json:"organization,omitempty"` + URL *string `json:"url,omitempty"` +} + +func (c Classroom) String() string { + return Stringify(c) +} + +// ClassroomAssignment represents a GitHub Classroom assignment. +type ClassroomAssignment struct { + ID *int64 `json:"id,omitempty"` + PublicRepo *bool `json:"public_repo,omitempty"` + Title *string `json:"title,omitempty"` + Type *string `json:"type,omitempty"` + InviteLink *string `json:"invite_link,omitempty"` + InvitationsEnabled *bool `json:"invitations_enabled,omitempty"` + Slug *string `json:"slug,omitempty"` + StudentsAreRepoAdmins *bool `json:"students_are_repo_admins,omitempty"` + FeedbackPullRequestsEnabled *bool `json:"feedback_pull_requests_enabled,omitempty"` + MaxTeams *int `json:"max_teams,omitempty"` + MaxMembers *int `json:"max_members,omitempty"` + Editor *string `json:"editor,omitempty"` + Accepted *int `json:"accepted,omitempty"` + Submitted *int `json:"submitted,omitempty"` + Passing *int `json:"passing,omitempty"` + Language *string `json:"language,omitempty"` + Deadline *Timestamp `json:"deadline,omitempty"` + StarterCodeRepository *Repository `json:"starter_code_repository,omitempty"` + Classroom *Classroom `json:"classroom,omitempty"` +} + +func (a ClassroomAssignment) String() string { + return Stringify(a) +} + +// GetAssignment gets a GitHub Classroom assignment. Assignment will only be +// returned if the current user is an administrator of the GitHub Classroom +// for the assignment. +// +// GitHub API docs: https://docs.github.com/rest/classroom/classroom#get-an-assignment +// +//meta:operation GET /assignments/{assignment_id} +func (s *ClassroomService) GetAssignment(ctx context.Context, assignmentID int64) (*ClassroomAssignment, *Response, error) { + u := fmt.Sprintf("assignments/%v", assignmentID) + + req, err := s.client.NewRequest(http.MethodGet, u, nil) + if err != nil { + return nil, nil, err + } + + assignment := new(ClassroomAssignment) + resp, err := s.client.Do(ctx, req, assignment) + if err != nil { + return nil, resp, err + } + + return assignment, resp, nil +} diff --git a/github/classroom_test.go b/github/classroom_test.go new file mode 100644 index 00000000000..a6c67f15180 --- /dev/null +++ b/github/classroom_test.go @@ -0,0 +1,211 @@ +// Copyright 2025 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" + "net/http" + "testing" + "time" + + "github.com/google/go-cmp/cmp" +) + +func TestClassroom_Marshal(t *testing.T) { + t.Parallel() + testJSONMarshal(t, &Classroom{}, "{}") + + c := &Classroom{ + ID: Ptr(int64(1296269)), + Name: Ptr("Programming Elixir"), + Archived: Ptr(false), + Organization: &Organization{ + ID: Ptr(int64(1)), + Login: Ptr("programming-elixir"), + NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjE="), + HTMLURL: Ptr("https://github.com/programming-elixir"), + Name: Ptr("Learn how to build fault tolerant applications"), + AvatarURL: Ptr("https://avatars.githubusercontent.com/u/9919?v=4"), + }, + URL: Ptr("https://classroom.github.com/classrooms/1-programming-elixir"), + } + + want := `{ + "id": 1296269, + "name": "Programming Elixir", + "archived": false, + "organization": { + "id": 1, + "login": "programming-elixir", + "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", + "html_url": "https://github.com/programming-elixir", + "name": "Learn how to build fault tolerant applications", + "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4" + }, + "url": "https://classroom.github.com/classrooms/1-programming-elixir" + }` + + testJSONMarshal(t, c, want) +} + +func TestClassroomAssignment_Marshal(t *testing.T) { + t.Parallel() + testJSONMarshal(t, &ClassroomAssignment{}, "{}") + + a := &ClassroomAssignment{ + ID: Ptr(int64(12)), + PublicRepo: Ptr(false), + Title: Ptr("Intro to Binaries"), + Type: Ptr("individual"), + InviteLink: Ptr("https://classroom.github.com/a/Lx7jiUgx"), + InvitationsEnabled: Ptr(true), + Slug: Ptr("intro-to-binaries"), + StudentsAreRepoAdmins: Ptr(false), + FeedbackPullRequestsEnabled: Ptr(true), + MaxTeams: Ptr(0), + MaxMembers: Ptr(0), + Editor: Ptr("codespaces"), + Accepted: Ptr(100), + Submitted: Ptr(40), + Passing: Ptr(10), + Language: Ptr("ruby"), + Deadline: &Timestamp{referenceTime}, + StarterCodeRepository: &Repository{ + ID: Ptr(int64(1296269)), + FullName: Ptr("octocat/Hello-World"), + }, + Classroom: &Classroom{ + ID: Ptr(int64(1296269)), + Name: Ptr("Programming Elixir"), + }, + } + + want := `{ + "id": 12, + "public_repo": false, + "title": "Intro to Binaries", + "type": "individual", + "invite_link": "https://classroom.github.com/a/Lx7jiUgx", + "invitations_enabled": true, + "slug": "intro-to-binaries", + "students_are_repo_admins": false, + "feedback_pull_requests_enabled": true, + "max_teams": 0, + "max_members": 0, + "editor": "codespaces", + "accepted": 100, + "submitted": 40, + "passing": 10, + "language": "ruby", + "deadline": ` + referenceTimeStr + `, + "starter_code_repository": { + "id": 1296269, + "full_name": "octocat/Hello-World" + }, + "classroom": { + "id": 1296269, + "name": "Programming Elixir" + } + }` + + testJSONMarshal(t, a, want) +} + +func TestClassroomService_GetAssignment(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/assignments/12", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "id": 12, + "public_repo": false, + "title": "Intro to Binaries", + "type": "individual", + "invite_link": "https://classroom.github.com/a/Lx7jiUgx", + "invitations_enabled": true, + "slug": "intro-to-binaries", + "students_are_repo_admins": false, + "feedback_pull_requests_enabled": true, + "max_teams": 0, + "max_members": 0, + "editor": "codespaces", + "accepted": 100, + "submitted": 40, + "passing": 10, + "language": "ruby", + "deadline": "2011-01-26T19:06:43Z", + "starter_code_repository": { + "id": 1296269, + "full_name": "octocat/Hello-World", + "html_url": "https://github.com/octocat/Hello-World", + "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", + "private": false, + "default_branch": "main" + }, + "classroom": { + "id": 1296269, + "name": "Programming Elixir", + "archived": false, + "url": "https://classroom.github.com/classrooms/1-programming-elixir" + } + }`) + }) + + ctx := context.Background() + assignment, _, err := client.Classroom.GetAssignment(ctx, 12) + if err != nil { + t.Errorf("Classroom.GetAssignment returned error: %v", err) + } + + want := &ClassroomAssignment{ + ID: Ptr(int64(12)), + PublicRepo: Ptr(false), + Title: Ptr("Intro to Binaries"), + Type: Ptr("individual"), + InviteLink: Ptr("https://classroom.github.com/a/Lx7jiUgx"), + InvitationsEnabled: Ptr(true), + Slug: Ptr("intro-to-binaries"), + StudentsAreRepoAdmins: Ptr(false), + FeedbackPullRequestsEnabled: Ptr(true), + MaxTeams: Ptr(0), + MaxMembers: Ptr(0), + Editor: Ptr("codespaces"), + Accepted: Ptr(100), + Submitted: Ptr(40), + Passing: Ptr(10), + Language: Ptr("ruby"), + Deadline: func() *Timestamp { t, _ := time.Parse(time.RFC3339, "2011-01-26T19:06:43Z"); return &Timestamp{t} }(), + StarterCodeRepository: &Repository{ + ID: Ptr(int64(1296269)), + FullName: Ptr("octocat/Hello-World"), + HTMLURL: Ptr("https://github.com/octocat/Hello-World"), + NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), + Private: Ptr(false), + DefaultBranch: Ptr("main"), + }, + Classroom: &Classroom{ + ID: Ptr(int64(1296269)), + Name: Ptr("Programming Elixir"), + Archived: Ptr(false), + URL: Ptr("https://classroom.github.com/classrooms/1-programming-elixir"), + }, + } + + if !cmp.Equal(assignment, want) { + t.Errorf("Classroom.GetAssignment returned %+v, want %+v", assignment, want) + } + + const methodName = "GetAssignment" + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Classroom.GetAssignment(ctx, 12) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} diff --git a/github/github-accessors.go b/github/github-accessors.go index d0973b280b0..b860363e81d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -2526,6 +2526,198 @@ func (c *CheckSuitePreferenceResults) GetRepository() *Repository { return c.Repository } +// GetArchived returns the Archived field if it's non-nil, zero value otherwise. +func (c *Classroom) GetArchived() bool { + if c == nil || c.Archived == nil { + return false + } + return *c.Archived +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (c *Classroom) GetID() int64 { + if c == nil || c.ID == nil { + return 0 + } + return *c.ID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *Classroom) GetName() string { + if c == nil || c.Name == nil { + return "" + } + return *c.Name +} + +// GetOrganization returns the Organization field. +func (c *Classroom) GetOrganization() *Organization { + if c == nil { + return nil + } + return c.Organization +} + +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (c *Classroom) GetURL() string { + if c == nil || c.URL == nil { + return "" + } + return *c.URL +} + +// GetAccepted returns the Accepted field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetAccepted() int { + if c == nil || c.Accepted == nil { + return 0 + } + return *c.Accepted +} + +// GetClassroom returns the Classroom field. +func (c *ClassroomAssignment) GetClassroom() *Classroom { + if c == nil { + return nil + } + return c.Classroom +} + +// GetDeadline returns the Deadline field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetDeadline() Timestamp { + if c == nil || c.Deadline == nil { + return Timestamp{} + } + return *c.Deadline +} + +// GetEditor returns the Editor field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetEditor() string { + if c == nil || c.Editor == nil { + return "" + } + return *c.Editor +} + +// GetFeedbackPullRequestsEnabled returns the FeedbackPullRequestsEnabled field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetFeedbackPullRequestsEnabled() bool { + if c == nil || c.FeedbackPullRequestsEnabled == nil { + return false + } + return *c.FeedbackPullRequestsEnabled +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetID() int64 { + if c == nil || c.ID == nil { + return 0 + } + return *c.ID +} + +// GetInvitationsEnabled returns the InvitationsEnabled field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetInvitationsEnabled() bool { + if c == nil || c.InvitationsEnabled == nil { + return false + } + return *c.InvitationsEnabled +} + +// GetInviteLink returns the InviteLink field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetInviteLink() string { + if c == nil || c.InviteLink == nil { + return "" + } + return *c.InviteLink +} + +// GetLanguage returns the Language field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetLanguage() string { + if c == nil || c.Language == nil { + return "" + } + return *c.Language +} + +// GetMaxMembers returns the MaxMembers field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetMaxMembers() int { + if c == nil || c.MaxMembers == nil { + return 0 + } + return *c.MaxMembers +} + +// GetMaxTeams returns the MaxTeams field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetMaxTeams() int { + if c == nil || c.MaxTeams == nil { + return 0 + } + return *c.MaxTeams +} + +// GetPassing returns the Passing field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetPassing() int { + if c == nil || c.Passing == nil { + return 0 + } + return *c.Passing +} + +// GetPublicRepo returns the PublicRepo field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetPublicRepo() bool { + if c == nil || c.PublicRepo == nil { + return false + } + return *c.PublicRepo +} + +// GetSlug returns the Slug field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetSlug() string { + if c == nil || c.Slug == nil { + return "" + } + return *c.Slug +} + +// GetStarterCodeRepository returns the StarterCodeRepository field. +func (c *ClassroomAssignment) GetStarterCodeRepository() *Repository { + if c == nil { + return nil + } + return c.StarterCodeRepository +} + +// GetStudentsAreRepoAdmins returns the StudentsAreRepoAdmins field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetStudentsAreRepoAdmins() bool { + if c == nil || c.StudentsAreRepoAdmins == nil { + return false + } + return *c.StudentsAreRepoAdmins +} + +// GetSubmitted returns the Submitted field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetSubmitted() int { + if c == nil || c.Submitted == nil { + return 0 + } + return *c.Submitted +} + +// GetTitle returns the Title field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetTitle() string { + if c == nil || c.Title == nil { + return "" + } + return *c.Title +} + +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (c *ClassroomAssignment) GetType() string { + if c == nil || c.Type == nil { + return "" + } + return *c.Type +} + // GetFingerprint returns the Fingerprint field if it's non-nil, zero value otherwise. func (c *ClusterSSHKey) GetFingerprint() string { if c == nil || c.Fingerprint == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index dbc78f046ba..245b85bbfd2 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -3277,6 +3277,261 @@ func TestCheckSuitePreferenceResults_GetRepository(tt *testing.T) { c.GetRepository() } +func TestClassroom_GetArchived(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &Classroom{Archived: &zeroValue} + c.GetArchived() + c = &Classroom{} + c.GetArchived() + c = nil + c.GetArchived() +} + +func TestClassroom_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + c := &Classroom{ID: &zeroValue} + c.GetID() + c = &Classroom{} + c.GetID() + c = nil + c.GetID() +} + +func TestClassroom_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &Classroom{Name: &zeroValue} + c.GetName() + c = &Classroom{} + c.GetName() + c = nil + c.GetName() +} + +func TestClassroom_GetOrganization(tt *testing.T) { + tt.Parallel() + c := &Classroom{} + c.GetOrganization() + c = nil + c.GetOrganization() +} + +func TestClassroom_GetURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &Classroom{URL: &zeroValue} + c.GetURL() + c = &Classroom{} + c.GetURL() + c = nil + c.GetURL() +} + +func TestClassroomAssignment_GetAccepted(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &ClassroomAssignment{Accepted: &zeroValue} + c.GetAccepted() + c = &ClassroomAssignment{} + c.GetAccepted() + c = nil + c.GetAccepted() +} + +func TestClassroomAssignment_GetClassroom(tt *testing.T) { + tt.Parallel() + c := &ClassroomAssignment{} + c.GetClassroom() + c = nil + c.GetClassroom() +} + +func TestClassroomAssignment_GetDeadline(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + c := &ClassroomAssignment{Deadline: &zeroValue} + c.GetDeadline() + c = &ClassroomAssignment{} + c.GetDeadline() + c = nil + c.GetDeadline() +} + +func TestClassroomAssignment_GetEditor(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &ClassroomAssignment{Editor: &zeroValue} + c.GetEditor() + c = &ClassroomAssignment{} + c.GetEditor() + c = nil + c.GetEditor() +} + +func TestClassroomAssignment_GetFeedbackPullRequestsEnabled(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &ClassroomAssignment{FeedbackPullRequestsEnabled: &zeroValue} + c.GetFeedbackPullRequestsEnabled() + c = &ClassroomAssignment{} + c.GetFeedbackPullRequestsEnabled() + c = nil + c.GetFeedbackPullRequestsEnabled() +} + +func TestClassroomAssignment_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + c := &ClassroomAssignment{ID: &zeroValue} + c.GetID() + c = &ClassroomAssignment{} + c.GetID() + c = nil + c.GetID() +} + +func TestClassroomAssignment_GetInvitationsEnabled(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &ClassroomAssignment{InvitationsEnabled: &zeroValue} + c.GetInvitationsEnabled() + c = &ClassroomAssignment{} + c.GetInvitationsEnabled() + c = nil + c.GetInvitationsEnabled() +} + +func TestClassroomAssignment_GetInviteLink(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &ClassroomAssignment{InviteLink: &zeroValue} + c.GetInviteLink() + c = &ClassroomAssignment{} + c.GetInviteLink() + c = nil + c.GetInviteLink() +} + +func TestClassroomAssignment_GetLanguage(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &ClassroomAssignment{Language: &zeroValue} + c.GetLanguage() + c = &ClassroomAssignment{} + c.GetLanguage() + c = nil + c.GetLanguage() +} + +func TestClassroomAssignment_GetMaxMembers(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &ClassroomAssignment{MaxMembers: &zeroValue} + c.GetMaxMembers() + c = &ClassroomAssignment{} + c.GetMaxMembers() + c = nil + c.GetMaxMembers() +} + +func TestClassroomAssignment_GetMaxTeams(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &ClassroomAssignment{MaxTeams: &zeroValue} + c.GetMaxTeams() + c = &ClassroomAssignment{} + c.GetMaxTeams() + c = nil + c.GetMaxTeams() +} + +func TestClassroomAssignment_GetPassing(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &ClassroomAssignment{Passing: &zeroValue} + c.GetPassing() + c = &ClassroomAssignment{} + c.GetPassing() + c = nil + c.GetPassing() +} + +func TestClassroomAssignment_GetPublicRepo(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &ClassroomAssignment{PublicRepo: &zeroValue} + c.GetPublicRepo() + c = &ClassroomAssignment{} + c.GetPublicRepo() + c = nil + c.GetPublicRepo() +} + +func TestClassroomAssignment_GetSlug(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &ClassroomAssignment{Slug: &zeroValue} + c.GetSlug() + c = &ClassroomAssignment{} + c.GetSlug() + c = nil + c.GetSlug() +} + +func TestClassroomAssignment_GetStarterCodeRepository(tt *testing.T) { + tt.Parallel() + c := &ClassroomAssignment{} + c.GetStarterCodeRepository() + c = nil + c.GetStarterCodeRepository() +} + +func TestClassroomAssignment_GetStudentsAreRepoAdmins(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &ClassroomAssignment{StudentsAreRepoAdmins: &zeroValue} + c.GetStudentsAreRepoAdmins() + c = &ClassroomAssignment{} + c.GetStudentsAreRepoAdmins() + c = nil + c.GetStudentsAreRepoAdmins() +} + +func TestClassroomAssignment_GetSubmitted(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &ClassroomAssignment{Submitted: &zeroValue} + c.GetSubmitted() + c = &ClassroomAssignment{} + c.GetSubmitted() + c = nil + c.GetSubmitted() +} + +func TestClassroomAssignment_GetTitle(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &ClassroomAssignment{Title: &zeroValue} + c.GetTitle() + c = &ClassroomAssignment{} + c.GetTitle() + c = nil + c.GetTitle() +} + +func TestClassroomAssignment_GetType(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &ClassroomAssignment{Type: &zeroValue} + c.GetType() + c = &ClassroomAssignment{} + c.GetType() + c = nil + c.GetType() +} + func TestClusterSSHKey_GetFingerprint(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index abbe7f6b8c0..0b27ee1817c 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -228,6 +228,50 @@ func TestCheckSuite_String(t *testing.T) { } } +func TestClassroom_String(t *testing.T) { + t.Parallel() + v := Classroom{ + ID: Ptr(int64(0)), + Name: Ptr(""), + Archived: Ptr(false), + Organization: &Organization{}, + URL: Ptr(""), + } + want := `github.Classroom{ID:0, Name:"", Archived:false, Organization:github.Organization{}, URL:""}` + if got := v.String(); got != want { + t.Errorf("Classroom.String = %v, want %v", got, want) + } +} + +func TestClassroomAssignment_String(t *testing.T) { + t.Parallel() + v := ClassroomAssignment{ + ID: Ptr(int64(0)), + PublicRepo: Ptr(false), + Title: Ptr(""), + Type: Ptr(""), + InviteLink: Ptr(""), + InvitationsEnabled: Ptr(false), + Slug: Ptr(""), + StudentsAreRepoAdmins: Ptr(false), + FeedbackPullRequestsEnabled: Ptr(false), + MaxTeams: Ptr(0), + MaxMembers: Ptr(0), + Editor: Ptr(""), + Accepted: Ptr(0), + Submitted: Ptr(0), + Passing: Ptr(0), + Language: Ptr(""), + Deadline: &Timestamp{}, + StarterCodeRepository: &Repository{}, + Classroom: &Classroom{}, + } + want := `github.ClassroomAssignment{ID:0, PublicRepo:false, Title:"", Type:"", InviteLink:"", InvitationsEnabled:false, Slug:"", StudentsAreRepoAdmins:false, FeedbackPullRequestsEnabled:false, MaxTeams:0, MaxMembers:0, Editor:"", Accepted:0, Submitted:0, Passing:0, Language:"", Deadline:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, StarterCodeRepository:github.Repository{}, Classroom:github.Classroom{}}` + if got := v.String(); got != want { + t.Errorf("ClassroomAssignment.String = %v, want %v", got, want) + } +} + func TestCodeOfConduct_String(t *testing.T) { t.Parallel() v := CodeOfConduct{ diff --git a/github/github.go b/github/github.go index bb81b00c104..97b0d143be5 100644 --- a/github/github.go +++ b/github/github.go @@ -197,6 +197,7 @@ type Client struct { Authorizations *AuthorizationsService Billing *BillingService Checks *ChecksService + Classroom *ClassroomService CodeScanning *CodeScanningService CodesOfConduct *CodesOfConductService Codespaces *CodespacesService @@ -434,6 +435,7 @@ func (c *Client) initialize() { c.Authorizations = (*AuthorizationsService)(&c.common) c.Billing = (*BillingService)(&c.common) c.Checks = (*ChecksService)(&c.common) + c.Classroom = (*ClassroomService)(&c.common) c.CodeScanning = (*CodeScanningService)(&c.common) c.Codespaces = (*CodespacesService)(&c.common) c.CodesOfConduct = (*CodesOfConductService)(&c.common)