2013-01-20 22:43:28 +04:00
|
|
|
|
Feature: hub ci-status
|
|
|
|
|
|
|
|
|
|
Background:
|
2013-05-14 12:00:16 +04:00
|
|
|
|
Given I am in "git://github.com/michiels/pencilbox.git" git repo
|
2013-01-20 22:43:28 +04:00
|
|
|
|
And I am "michiels" on github.com with OAuth token "OTOKEN"
|
|
|
|
|
|
|
|
|
|
Scenario: Fetch commit SHA
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "the_sha" is "success"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
When I run `hub ci-status the_sha`
|
|
|
|
|
Then the output should contain exactly "success\n"
|
|
|
|
|
And the exit status should be 0
|
|
|
|
|
|
2013-10-29 03:56:00 +04:00
|
|
|
|
Scenario: Fetch commit SHA with URL
|
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "the_sha" is "success"
|
|
|
|
|
When I run `hub ci-status the_sha -v`
|
2015-09-27 02:04:56 +03:00
|
|
|
|
Then the output should contain exactly:
|
|
|
|
|
"""
|
|
|
|
|
✔︎ continuous-integration/travis-ci/push https://travis-ci.org/michiels/pencilbox/builds/1234567\n
|
|
|
|
|
"""
|
2013-10-29 03:56:00 +04:00
|
|
|
|
And the exit status should be 0
|
|
|
|
|
|
2015-09-27 02:04:56 +03:00
|
|
|
|
Scenario: Multiple statuses with verbose output
|
2013-04-26 19:53:31 +04:00
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit states of "michiels/pencilbox" "the_sha" are:
|
|
|
|
|
"""
|
2015-09-27 02:04:56 +03:00
|
|
|
|
{ :state => "pending",
|
|
|
|
|
:statuses => [
|
|
|
|
|
{ :state => "success",
|
|
|
|
|
:context => "continuous-integration/travis-ci/push",
|
|
|
|
|
:target_url => "https://travis-ci.org/michiels/pencilbox/builds/1234567" },
|
|
|
|
|
{ :state => "pending",
|
|
|
|
|
:context => "continuous-integration/travis-ci/merge",
|
2015-09-28 14:25:48 +03:00
|
|
|
|
:target_url => nil },
|
2015-09-27 02:04:56 +03:00
|
|
|
|
{ :state => "failure",
|
|
|
|
|
:context => "GitHub CLA",
|
|
|
|
|
:target_url => "https://cla.github.com/michiels/pencilbox/accept/mislav" },
|
2015-09-28 14:25:48 +03:00
|
|
|
|
{ :state => "error",
|
|
|
|
|
:context => "whatevs!" }
|
2015-09-27 02:04:56 +03:00
|
|
|
|
]
|
|
|
|
|
}
|
2013-04-26 19:53:31 +04:00
|
|
|
|
"""
|
2015-09-27 02:04:56 +03:00
|
|
|
|
When I run `hub ci-status -v the_sha`
|
|
|
|
|
Then the output should contain exactly:
|
|
|
|
|
"""
|
|
|
|
|
✔︎ continuous-integration/travis-ci/push https://travis-ci.org/michiels/pencilbox/builds/1234567
|
2015-09-28 14:25:48 +03:00
|
|
|
|
● continuous-integration/travis-ci/merge
|
|
|
|
|
✖︎ GitHub CLA https://cla.github.com/michiels/pencilbox/accept/mislav
|
|
|
|
|
✖︎ whatevs!\n
|
2015-09-27 02:04:56 +03:00
|
|
|
|
"""
|
|
|
|
|
And the exit status should be 2
|
2013-04-26 19:53:31 +04:00
|
|
|
|
|
2013-01-20 22:43:28 +04:00
|
|
|
|
Scenario: Exit status 1 for 'error' and 'failure'
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "HEAD" is "error"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
When I run `hub ci-status`
|
|
|
|
|
Then the exit status should be 1
|
2013-01-30 01:08:26 +04:00
|
|
|
|
And the output should contain exactly "error\n"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
|
|
|
|
|
Scenario: Use HEAD when no sha given
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "HEAD" is "pending"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
When I run `hub ci-status`
|
|
|
|
|
Then the exit status should be 2
|
2013-01-30 01:08:26 +04:00
|
|
|
|
And the output should contain exactly "pending\n"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
|
|
|
|
|
Scenario: Exit status 3 for no statuses available
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "the_sha" is nil
|
2013-01-20 22:43:28 +04:00
|
|
|
|
When I run `hub ci-status the_sha`
|
|
|
|
|
Then the output should contain exactly "no status\n"
|
|
|
|
|
And the exit status should be 3
|
|
|
|
|
|
2013-10-29 03:56:00 +04:00
|
|
|
|
Scenario: Exit status 3 for no statuses available without URL
|
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "the_sha" is nil
|
|
|
|
|
When I run `hub ci-status -v the_sha`
|
|
|
|
|
Then the output should contain exactly "no status\n"
|
|
|
|
|
And the exit status should be 3
|
|
|
|
|
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Scenario: Abort with message when invalid ref given
|
|
|
|
|
When I run `hub ci-status this-is-an-invalid-ref`
|
|
|
|
|
Then the exit status should be 1
|
|
|
|
|
And the output should contain exactly "Aborted: no revision could be determined from 'this-is-an-invalid-ref'\n"
|
|
|
|
|
|
2013-01-20 22:43:28 +04:00
|
|
|
|
Scenario: Non-GitHub repo
|
|
|
|
|
Given the "origin" remote has url "mygh:Manganeez/repo.git"
|
|
|
|
|
When I run `hub ci-status`
|
|
|
|
|
Then the stderr should contain "Aborted: the origin remote doesn't point to a GitHub repository.\n"
|
2013-01-30 01:08:26 +04:00
|
|
|
|
And the exit status should be 1
|
2016-05-03 17:59:19 +03:00
|
|
|
|
|
|
|
|
|
Scenario: Enterprise CI statuses
|
|
|
|
|
Given the "origin" remote has url "git@git.my.org:michiels/pencilbox.git"
|
|
|
|
|
And I am "michiels" on git.my.org with OAuth token "FITOKEN"
|
|
|
|
|
And "git.my.org" is a whitelisted Enterprise host
|
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "git.my.org/michiels/pencilbox" "the_sha" is "success"
|
|
|
|
|
When I successfully run `hub ci-status the_sha`
|
|
|
|
|
Then the output should contain exactly "success\n"
|