Skip to content

Commit

Permalink
Renamed checkIfIssue function to checkIfIssueExists
Browse files Browse the repository at this point in the history
This is a more appropiate name as the function only checks if the issue
exists, and doesn't have any more criteria to validate it.
  • Loading branch information
Simon Lutz Brüggen committed Oct 15, 2018
1 parent 239c317 commit 388b9cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func main() {

// Loop over all issues and check if they are correct / valid
for _, issueFromUser := range issues {
err := checkIfIssue(issueFromUser, jiraClient)
err := checkIfIssueExists(issueFromUser, jiraClient)
if err != nil {
logger.Fatal(err)
}
Expand Down Expand Up @@ -111,9 +111,9 @@ func getIssuesOutOfMessage(projects []string, message string) []string {
return issues
}

// checkIfIssue checks if issue exists in the JIRA instance.
// checkIfIssueExists checks if issue exists in the JIRA instance.
// If not an error will be returned.
func checkIfIssue(issue string, jiraClient *jira.Client) error {
func checkIfIssueExists(issue string, jiraClient *jira.Client) error {
JIRAIssue, resp, err := jiraClient.Issue.Get(issue, nil)
if c := resp.StatusCode; err != nil || (c < 200 || c > 299) {
return fmt.Errorf("JIRA Request for issue %s returned %s (%d)", issue, resp.Status, resp.StatusCode)
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func teardown() {
server.Close()
}

func TestGetJIRAClient_IssueNotExists(t *testing.T) {
func TestGetJIRAClient_IssueDoesNotExist(t *testing.T) {
setup()
defer teardown()

Expand All @@ -48,7 +48,7 @@ func TestGetJIRAClient_IssueNotExists(t *testing.T) {
w.WriteHeader(http.StatusNotFound)
})

err = checkIfIssue("WEB-1234", c)
err = checkIfIssueExists("WEB-1234", c)
if err == nil {
t.Error("No error occuered. Expected a 404")
}
Expand Down

0 comments on commit 388b9cb

Please sign in to comment.