Improve Error Handling #351

Merged
techknowlogick merged 6 commits from 6543/go-sdk:impruve-error-handling into master 2020-07-08 17:21:48 +00:00
4 changed files with 8 additions and 4 deletions
Showing only changes of commit 2574e4afe6 - Show all commits

View File

@ -44,6 +44,7 @@ type Issue struct {
Assignees []*User `json:"assignees"`
// Whether the issue is open or closed
State StateType `json:"state"`
IsLocked bool `json:"is_locked"`
Comments int `json:"comments"`
Created time.Time `json:"created_at"`
Updated time.Time `json:"updated_at"`

View File

@ -77,7 +77,7 @@ func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption)
type EditMilestoneOption struct {
Title string `json:"title"`
Description *string `json:"description"`
State *string `json:"state"`
State *StateType `json:"state"`
Deadline *time.Time `json:"due_on"`
}

View File

@ -20,6 +20,7 @@ func TestMilestones(t *testing.T) {
now := time.Now()
future := time.Unix(1896134400, 0) //2030-02-01
closed := "closed"
sClosed := StateClosed
// CreateMilestone 4x
m1, err := c.CreateMilestone(repo.Owner.UserName, repo.Name, CreateMilestoneOption{Title: "v1.0", Description: "First Version", Deadline: &now})
@ -32,7 +33,7 @@ func TestMilestones(t *testing.T) {
assert.NoError(t, err)
// EditMilestone
m1, err = c.EditMilestone(repo.Owner.UserName, repo.Name, m1.ID, EditMilestoneOption{Description: &closed, State: &closed})
m1, err = c.EditMilestone(repo.Owner.UserName, repo.Name, m1.ID, EditMilestoneOption{Description: &closed, State: &sClosed})
assert.NoError(t, err)
// DeleteMilestone
@ -42,10 +43,10 @@ func TestMilestones(t *testing.T) {
ml, err := c.ListRepoMilestones(repo.Owner.UserName, repo.Name, ListMilestoneOption{})
assert.NoError(t, err)
assert.Len(t, ml, 2)
ml, err = c.ListRepoMilestones(repo.Owner.UserName, repo.Name, ListMilestoneOption{State: "closed"})
ml, err = c.ListRepoMilestones(repo.Owner.UserName, repo.Name, ListMilestoneOption{State: StateClosed})
assert.NoError(t, err)
assert.Len(t, ml, 1)
ml, err = c.ListRepoMilestones(repo.Owner.UserName, repo.Name, ListMilestoneOption{State: "all"})
ml, err = c.ListRepoMilestones(repo.Owner.UserName, repo.Name, ListMilestoneOption{State: StateAll})
assert.NoError(t, err)
assert.Len(t, ml, 3)

View File

@ -35,6 +35,7 @@ type PullRequest struct {
Assignee *User `json:"assignee"`
Assignees []*User `json:"assignees"`
State StateType `json:"state"`
IsLocked bool `json:"is_locked"`
Comments int `json:"comments"`
HTMLURL string `json:"html_url"`
@ -139,6 +140,7 @@ func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOpti
type EditPullRequestOption struct {
Title string `json:"title"`
Body string `json:"body"`
Base string `json:"base"`
Assignee string `json:"assignee"`
Assignees []string `json:"assignees"`
Milestone int64 `json:"milestone"`