Created
December 22, 2016 09:03
-
-
Save haya14busa/b561b5c0df8475b34799d076253600e5 to your computer and use it in GitHub Desktop.
test go-github review API (ListReviews/GetReviews/ListReviewComments)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/google/go-github/github" | |
) | |
func main() { | |
if err := run(); err != nil { | |
log.Fatal(err) | |
} | |
} | |
func run() error { | |
const ( | |
owner = "google" | |
repo = "go-github" | |
number = 497 | |
) | |
cli := github.NewClient(nil) | |
reviews, resp, err := cli.PullRequests.ListReviews(owner, repo, number) | |
if err != nil { | |
return err | |
} | |
log.Println("resp.Rate.Remaining", resp.Rate.Remaining) | |
for _, review := range reviews { | |
r, _, err := cli.PullRequests.GetReview(owner, repo, number, *review.ID) | |
if err != nil { | |
return fmt.Errorf("fail to GetReview(): id=%v err=%v", *review.ID, err) | |
} | |
log.Printf("GetReview: ok id=%v", r.ID) | |
// ListReviewComments doesn't work now due to GitHub API problem | |
// https://github.com/google/go-github/pull/497#discussion_r92933362 | |
if false { | |
comments, _, err := cli.PullRequests.ListReviewComments(owner, repo, number, *review.ID) | |
if err != nil { | |
return fmt.Errorf("fail to ListReviewComments(): id=%v err=%v", *review.ID, err) | |
} | |
log.Printf("ListReviewComments: ok len(comments)=%v", len(comments)) | |
} | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment