forked from concourse/github-release-resource
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix some err checks * github api url can be configured (e.g. point it at an enterprise instance) [finishes #89638752 #89633744] Signed-off-by: Chris Brown <[email protected]>
- Loading branch information
Showing
9 changed files
with
174 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package resource_test | ||
|
||
import ( | ||
"net/http" | ||
|
||
. "github.com/concourse/github-release-resource" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/onsi/gomega/ghttp" | ||
) | ||
|
||
var _ = Describe("GitHub Client", func() { | ||
var server *ghttp.Server | ||
var client *GitHubClient | ||
var source Source | ||
|
||
BeforeEach(func() { | ||
server = ghttp.NewServer() | ||
}) | ||
|
||
JustBeforeEach(func() { | ||
source.GitHubAPIURL = server.URL() | ||
|
||
var err error | ||
client, err = NewGitHubClient(source) | ||
Ω(err).ShouldNot(HaveOccurred()) | ||
}) | ||
|
||
AfterEach(func() { | ||
server.Close() | ||
}) | ||
|
||
Context("with an OAuth Token", func() { | ||
BeforeEach(func() { | ||
source = Source{ | ||
User: "concourse", | ||
Repository: "concourse", | ||
AccessToken: "abc123", | ||
} | ||
|
||
server.AppendHandlers( | ||
ghttp.CombineHandlers( | ||
ghttp.VerifyRequest("GET", "/repos/concourse/concourse/releases"), | ||
ghttp.RespondWith(200, "[]"), | ||
ghttp.VerifyHeaderKV("Authorization", "Bearer abc123"), | ||
), | ||
) | ||
}) | ||
|
||
It("sends one", func() { | ||
_, err := client.ListReleases() | ||
Ω(err).ShouldNot(HaveOccurred()) | ||
}) | ||
}) | ||
|
||
Context("without an OAuth Token", func() { | ||
BeforeEach(func() { | ||
source = Source{ | ||
User: "concourse", | ||
Repository: "concourse", | ||
} | ||
|
||
server.AppendHandlers( | ||
ghttp.CombineHandlers( | ||
ghttp.VerifyRequest("GET", "/repos/concourse/concourse/releases"), | ||
ghttp.RespondWith(200, "[]"), | ||
ghttp.VerifyHeader(http.Header{"Authorization": nil}), | ||
), | ||
) | ||
}) | ||
|
||
It("sends one", func() { | ||
_, err := client.ListReleases() | ||
Ω(err).ShouldNot(HaveOccurred()) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters