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

Code before:
		got, resp, err := client.Organizations.ListImmutableReleaseRepositories(ctx, "o", opts)
		if got != nil {
			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
		}
		return resp, err
	})
}

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

	input := []int64{1, 2, 3}
	mux.HandleFunc("/orgs/o/settings/immutable-releases/repositories", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, "PUT")

		var gotBody []int64
		if err := json.NewDecoder(r.Body).Decode(&gotBody); err != nil {
			t.Fatalf("Failed to decode request body: %v", err)
		}

		if !cmp.Equal(gotBody, input) {
			t.Errorf("Request body = %+v, want %+v", gotBody, input)
		}

		w.WriteHeader(http.StatusOK)
	})

	ctx := t.Context()
	resp, err := client.Organizations.SetImmutableReleaseRepositories(ctx, "o", input)
	if err != nil {
		t.Fatalf("SetImmutableReleaseRepositories returned error: %v", err)
	}

	if resp.StatusCode != http.StatusOK {
		t.Errorf("Expected status 200 OK, got %v", resp.StatusCode)
	}

	const methodName = "SetImmutableReleaseRepositories"

	testBadOptions(t, methodName, func() error {
		_, err := client.Organizations.SetImmutableReleaseRepositories(ctx, "\n", input)
		return err
	})

	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
		return client.Organizations.SetImmutableReleaseRepositories(ctx, "o", input)
	})
}

func TestOrganizationsService_EnableRepositoryForImmutableRelease(t *testing.T) {

Review comment (suggestion):
```suggestion
		w.WriteHeader(http.StatusNoContent)
```

Code after:
		return resp, err
	})
}

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

	input := []int64{1, 2, 3}
	mux.HandleFunc("/orgs/o/settings/immutable-releases/repositories", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, "PUT")

		var gotBody setImmutableReleasesRepositoriesOptions
		if err := json.NewDecoder(r.Body).Decode(&gotBody); err != nil {
			t.Fatalf("Failed to decode request body: %v", err)
		}

		if !cmp.Equal(gotBody.SelectedRepositoryIDs, input) {
			t.Errorf("Request body = %+v, want %+v", gotBody.SelectedRepositoryIDs, input)
		}

		w.WriteHeader(http.StatusNoContent)
	})

	ctx := t.Context()
	resp, err := client.Organizations.SetImmutableReleaseRepositories(ctx, "o", input)
	if err != nil {
		t.Fatalf("SetImmutableReleaseRepositories returned error: %v", err)
	}

	if resp.StatusCode != http.StatusNoContent {
		t.Errorf("Expected status 204 No Content, got %v", resp.StatusCode)
	}

	const methodName = "SetImmutableReleaseRepositories"

	testBadOptions(t, methodName, func() error {
		_, err := client.Organizations.SetImmutableReleaseRepositories(ctx, "\n", input)
		return err
	})

	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
		return client.Organizations.SetImmutableReleaseRepositories(ctx, "o", input)
	})
}

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

	repoID := int64(42)