Repository: google/go-github
File: github/classroom_test.go (Go)

Code before:
			URL:      Ptr("https://example.com/classrooms/programming"),
		},
		{
			ID:       Ptr(int64(1296270)),
			Name:     Ptr("Advanced Programming"),
			Archived: Ptr(true),
			URL:      Ptr("https://example.com/classrooms/2-advanced-programming"),
		},
	}

	if !cmp.Equal(classrooms, want) {
		t.Errorf("Classroom.ListClassrooms returned %+v, want %+v", classrooms, want)
	}

	const methodName = "ListClassrooms"
	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
		got, resp, err := client.Classroom.ListClassrooms(ctx, opt)
		if got != nil {
			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
		}
		return resp, err
	})
}

func TestClassroomService_ListClassroomAssignments(t *testing.T) {
	t.Parallel()
	client, mux, _ := setup(t)

	mux.HandleFunc("/classrooms/1296269/assignments", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, "GET")
		testFormValues(t, r, values{"page": "2", "per_page": "2"})
		fmt.Fprint(w, `[
			{
				"id": 12,
				"public_repo": false,
				"title": "Intro to Binaries",
				"type": "individual",
				"invite_link": "https://example.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",
				"classroom": {

Review comment (suggestion):
And this here?

```
	testBadOptions(t, methodName, func() (err error) {
		_, _, err = client.Classroom.ListClassroom(ctx, opt)
		return err
	})
```

Code after:
	classrooms, _, err := client.Classroom.ListClassrooms(ctx, opt)
	if err != nil {
		t.Errorf("Classroom.ListClassrooms returned error: %v", err)
	}

	want := []*Classroom{
		{
			ID:       Ptr(int64(1296269)),
			Name:     Ptr("Programming Elixir"),
			Archived: Ptr(false),
			URL:      Ptr("https://example.com/classrooms/programming"),
		},
		{
			ID:       Ptr(int64(1296270)),
			Name:     Ptr("Advanced Programming"),
			Archived: Ptr(true),
			URL:      Ptr("https://example.com/classrooms/2-advanced-programming"),
		},
	}

	if !cmp.Equal(classrooms, want) {
		t.Errorf("Classroom.ListClassrooms returned %+v, want %+v", classrooms, want)
	}

	const methodName = "ListClassrooms"
	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
		got, resp, err := client.Classroom.ListClassrooms(ctx, opt)
		if got != nil {
			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
		}
		return resp, err
	})
}

func TestClassroomService_ListClassroomAssignments(t *testing.T) {
	t.Parallel()
	client, mux, _ := setup(t)

	mux.HandleFunc("/classrooms/1296269/assignments", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, "GET")
		testFormValues(t, r, values{"page": "2", "per_page": "2"})
		fmt.Fprint(w, `[
			{
				"id": 12,
				"public_repo": false,
				"title": "Intro to Binaries",
				"type": "individual",
				"invite_link": "https://example.com/a/Lx7jiUgx",
				"invitations_enabled": true,
				"slug": "intro-to-binaries",
				"students_are_repo_admins": false,