Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleyfalzon committed Aug 11, 2017
1 parent c78e0cf commit c6197cf
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion internal/github/reporters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ func TestCommitCommentReporter_report(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}
if diff := cmp.Diff(expected, comment); diff != "" {
//if !reflect.DeepEqual(expected, comment) {
t.Fatalf("expected cmt: (-have +want)\n%s", diff)
}
default:
Expand All @@ -268,3 +267,47 @@ func TestCommitCommentReporter_report(t *testing.T) {
}
}
}

func TestInlineCommitCommentReporter_report(t *testing.T) {
var (
expectedOwner = "owner"
expectedRepo = "repo"
expectedCmtBody = "body"
expectedCmtPath = "path"
expectedCmtPos = 4
expectedSHA = "abc123"
)

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
decoder := json.NewDecoder(r.Body)
switch r.RequestURI {
case fmt.Sprintf("/repos/%v/%v/commits/%v/comments", expectedOwner, expectedRepo, expectedSHA):
expected := github.RepositoryComment{
Body: github.String(expectedCmtBody),
Path: github.String(expectedCmtPath),
Position: github.Int(expectedCmtPos),
}
var comment github.RepositoryComment
err := decoder.Decode(&comment)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if diff := cmp.Diff(expected, comment); diff != "" {
t.Fatalf("expected cmt: (-have +want)\n%s", diff)
}
default:
t.Logf(r.RequestURI)
}
}))
defer ts.Close()

r := NewInlineCommitCommentReporter(github.NewClient(nil), expectedOwner, expectedRepo, expectedSHA)
r.client.BaseURL, _ = url.Parse(ts.URL)

var issues = []db.Issue{{Path: expectedCmtPath, HunkPos: expectedCmtPos, Issue: expectedCmtBody}}

err := r.Report(context.Background(), issues)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
}

0 comments on commit c6197cf

Please sign in to comment.