Browse Source

Adding Label struct that is in Issue

Yann Malet 13 years ago
committed by Will Norris
parent
commit
b416fdaac8
3 changed files with 43 additions and 1 deletions
  1. +2
    -1
      github/issues.go
  2. +21
    -0
      github/issues_labels.go
  3. +20
    -0
      github/issues_test.go

+ 2
- 1
github/issues.go View File

@ -28,13 +28,14 @@ type Issue struct {
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
User *User `json:"user,omitempty"`
Labels []Label `json:"labels,omitempty"`
Assignee *User `json:"assignee,omitempty"`
Comments int `json:"comments,omitempty"`
ClosedAt *time.Time `json:"closed_at,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
// TODO(willnorris): labels and milestone
// TODO(willnorris): milestone
}
// IssueListOptions specifies the optional parameters to the IssuesService.List


+ 21
- 0
github/issues_labels.go View File

@ -0,0 +1,21 @@
// Copyright 2013 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import
// Label represents a GitHib label on an Issue
"fmt"
type Label struct {
URL string `json:"url,omitempty"`
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`
}
func (label Label) String() string {
return fmt.Sprint(label.Name)
}

+ 20
- 0
github/issues_test.go View File

@ -69,6 +69,26 @@ func TestIssuesService_List_owned(t *testing.T) {
}
}
func TestIssueService_List_label(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/user/issues", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `[{"number":1, "labels": [{"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "color": "f29513"}]}]`)
})
issues, _, err := client.Issues.List(false, nil)
if err != nil {
t.Errorf("Issues.List returned error: %v", err)
}
want := []Issue{Issue{Number: 1, Labels: []Label{Label{URL: "https://api.github.com/repos/octocat/Hello-World/labels/bug", Name: "bug", Color: "f29513"}}}}
if !reflect.DeepEqual(issues, want) {
t.Errorf("Issues.List returned %+v, want %+v", issues, want)
}
}
func TestIssuesService_ListByOrg(t *testing.T) {
setup()
defer teardown()


Loading…
Cancel
Save