Skip to content

Commit

Permalink
label => labels, time => date, simpler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pcorpet committed Aug 19, 2016
1 parent f897f7d commit 99a0d87
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 72 deletions.
17 changes: 7 additions & 10 deletions commands/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ With no arguments, show a list of open issues.
When opening an issue, add a comma-separated list of labels to this issue.
-t, --since <TIME>
Display only issues updated at or after a certain time. The time is a
timestamp in ISO-8601 format: YYYY-MM-DDTHH:MM:SSZ.
-d, --since <DATE>
Display only issues updated at or after a certain date. The date is a
timestamp in ISO-8601 format: YYYY-MM-DDTHH:MM:SSZ however the second part
(after T is optional).
`,
}

Expand Down Expand Up @@ -162,8 +163,8 @@ func init() {
cmdIssue.Flag.StringVarP(&flagIssueMilestoneFilter, "milestone", "M", "", "MILESTONE")
cmdIssue.Flag.StringVarP(&flagIssueCreator, "creator", "c", "", "CREATOR")
cmdIssue.Flag.StringVarP(&flagIssueMentioned, "mentioned", "@", "", "USER")
cmdIssue.Flag.StringVarP(&flagIssueLabelsFilter, "label", "l", "", "LABELS")
cmdIssue.Flag.StringVarP(&flagIssueSince, "since", "t", "", "TIME")
cmdIssue.Flag.StringVarP(&flagIssueLabelsFilter, "labels", "l", "", "LABELS")
cmdIssue.Flag.StringVarP(&flagIssueSince, "since", "d", "", "DATE")

cmdIssue.Use(cmdCreateIssue)
CmdRunner.Use(cmdIssue)
Expand All @@ -187,6 +188,7 @@ func listIssues(cmd *Command, args *Args) {
"milestone": flagIssueMilestoneFilter,
"creator": flagIssueCreator,
"mentioned": flagIssueMentioned,
"labels": flagIssueLabelsFilter,
"since": flagIssueSince,
}
filters := map[string]interface{}{}
Expand All @@ -195,11 +197,6 @@ func listIssues(cmd *Command, args *Args) {
filters[flag] = filter
}
}
// Unfortunately hub does not use the same flag ("label") than the GitHub
// API ("labels").
if cmd.FlagPassed("label") {
filters["labels"] = flagIssueLabelsFilter
}

issues, err := gh.FetchIssues(project, filters)
utils.Check(err)
Expand Down
74 changes: 12 additions & 62 deletions features/issue.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,109 +37,59 @@ Feature: hub issue
get('/repos/github/hub/issues') {
assert :milestone => "none"
json [
{ :number => 102,
:title => "First issue",
:state => "open",
:user => { :login => "octocat" },
},
]
json []
}
"""
When I run `hub issue -M none`
Then the output should contain exactly:
"""
#102 First issue\n
"""
And the exit status should be 0
Then the exit status should be 0

Scenario: Fetch issues created by a given user
Given the GitHub API server:
"""
get('/repos/github/hub/issues') {
assert :creator => "octocat"
json [
{ :number => 102,
:title => "First issue",
:state => "open",
:user => { :login => "octocat" },
},
]
json []
}
"""
When I run `hub issue -c octocat`
Then the output should contain exactly:
"""
#102 First issue\n
"""
And the exit status should be 0
Then the exit status should be 0

Scenario: Fetch issues mentioning a given user
Given the GitHub API server:
"""
get('/repos/github/hub/issues') {
assert :mentioned => "octocat"
json [
{ :number => 102,
:title => "First issue",
:state => "open",
:user => { :login => "octocat" },
},
]
json []
}
"""
When I run `hub issue -@ octocat`
Then the output should contain exactly:
"""
#102 First issue\n
"""
And the exit status should be 0
Then the exit status should be 0

Scenario: Fetch issues with certain labels
Given the GitHub API server:
"""
get('/repos/github/hub/issues') {
assert :labels => "foo,bar"
json [
{ :number => 102,
:title => "First issue",
:state => "open",
:user => { :login => "octocat" },
},
]
json []
}
"""
When I run `hub issue -l foo,bar`
Then the output should contain exactly:
"""
#102 First issue\n
"""
And the exit status should be 0
Then the exit status should be 0

Scenario: Fetch issues updated after a certain time
Scenario: Fetch issues updated after a certain date and time
Given the GitHub API server:
"""
get('/repos/github/hub/issues') {
assert :since => "2016-08-18T09:11:32Z"
json [
{ :number => 102,
:title => "First issue",
:state => "open",
:user => { :login => "octocat" },
},
]
json []
}
"""
When I run `hub issue -t 2016-08-18T09:11:32Z`
Then the output should contain exactly:
"""
#102 First issue\n
"""
And the exit status should be 0
When I run `hub issue -d 2016-08-18T09:11:32Z`
Then the exit status should be 0

Scenario: Fetch issues across multiple pages
Given the GitHub API server:
Expand Down

0 comments on commit 99a0d87

Please sign in to comment.