feat(github): implement Reviewer and Identity interfaces (#81) #105
+3
-1
@@ -194,7 +194,9 @@ func (c *Client) DismissReview(ctx context.Context, owner, repo string, number i
|
|||||||
|
|
||||||
payload := dismissReviewRequest{
|
payload := dismissReviewRequest{
|
||||||
|
|
|||||||
Message: message,
|
Message: message,
|
||||||
Event: "DISMISS",
|
// Event is required by the GitHub API for dismissal requests, even though
|
||||||
|
// "DISMISS" is the only valid value for this endpoint.
|
||||||
|
Event: "DISMISS",
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.Marshal(payload)
|
data, err := json.Marshal(payload)
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ import (
|
|||||||
func TestPostReview_HappyPath(t *testing.T) {
|
func TestPostReview_HappyPath(t *testing.T) {
|
||||||
c := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
|
c := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != "POST" {
|
if r.Method != "POST" {
|
||||||
t.Errorf("expected POST, got %s", r.Method)
|
t.Fatalf("expected POST, got %s", r.Method)
|
||||||
}
|
}
|
||||||
if r.URL.Path != "/repos/owner/repo/pulls/5/reviews" {
|
if r.URL.Path != "/repos/owner/repo/pulls/5/reviews" {
|
||||||
t.Errorf("unexpected path: %s", r.URL.Path)
|
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||||
}
|
}
|
||||||
if r.Header.Get("Content-Type") != "application/json" {
|
if r.Header.Get("Content-Type") != "application/json" {
|
||||||
t.Errorf("expected Content-Type application/json, got %q", r.Header.Get("Content-Type"))
|
t.Errorf("expected Content-Type application/json, got %q", r.Header.Get("Content-Type"))
|
||||||
@@ -150,10 +150,10 @@ func TestPostReview_MalformedResponse(t *testing.T) {
|
|||||||
func TestListReviews_HappyPath(t *testing.T) {
|
func TestListReviews_HappyPath(t *testing.T) {
|
||||||
c := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
|
c := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != "GET" {
|
if r.Method != "GET" {
|
||||||
t.Errorf("expected GET, got %s", r.Method)
|
t.Fatalf("expected GET, got %s", r.Method)
|
||||||
}
|
}
|
||||||
if r.URL.Path != "/repos/owner/repo/pulls/3/reviews" {
|
if r.URL.Path != "/repos/owner/repo/pulls/3/reviews" {
|
||||||
t.Errorf("unexpected path: %s", r.URL.Path)
|
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||||
}
|
}
|
||||||
json.NewEncoder(w).Encode([]map[string]interface{}{
|
json.NewEncoder(w).Encode([]map[string]interface{}{
|
||||||
{
|
{
|
||||||
@@ -250,10 +250,10 @@ func TestListReviews_401(t *testing.T) {
|
|||||||
func TestDeleteReview_HappyPath(t *testing.T) {
|
func TestDeleteReview_HappyPath(t *testing.T) {
|
||||||
c := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
|
c := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != "DELETE" {
|
if r.Method != "DELETE" {
|
||||||
t.Errorf("expected DELETE, got %s", r.Method)
|
t.Fatalf("expected DELETE, got %s", r.Method)
|
||||||
}
|
}
|
||||||
if r.URL.Path != "/repos/owner/repo/pulls/5/reviews/42" {
|
if r.URL.Path != "/repos/owner/repo/pulls/5/reviews/42" {
|
||||||
t.Errorf("unexpected path: %s", r.URL.Path)
|
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||||
}
|
}
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
})
|
})
|
||||||
@@ -284,10 +284,10 @@ func TestDeleteReview_422_SubmittedReview(t *testing.T) {
|
|||||||
func TestDismissReview_HappyPath(t *testing.T) {
|
func TestDismissReview_HappyPath(t *testing.T) {
|
||||||
c := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
|
c := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != "PUT" {
|
if r.Method != "PUT" {
|
||||||
t.Errorf("expected PUT, got %s", r.Method)
|
t.Fatalf("expected PUT, got %s", r.Method)
|
||||||
}
|
}
|
||||||
if r.URL.Path != "/repos/owner/repo/pulls/5/reviews/10/dismissals" {
|
if r.URL.Path != "/repos/owner/repo/pulls/5/reviews/10/dismissals" {
|
||||||
t.Errorf("unexpected path: %s", r.URL.Path)
|
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
body, _ := io.ReadAll(r.Body)
|
body, _ := io.ReadAll(r.Body)
|
||||||
|
|||||||
Reference in New Issue
Block a user
[NIT] The
DismissReviewmethod hardcodesEvent: "DISMISS"in the payload struct. Since this is the only valid value for a dismissal, it's not a bug, but a small comment noting why the field is included (GitHub API requires it) would improve readability for future maintainers.Fixed in
dbc25f4— added a comment explaining that the GitHub API requires theEventfield for dismissal requests even thoughDISMISSis the only valid value.