Skip to content

Commit

Permalink
fix pat test messages (#2987)
Browse files Browse the repository at this point in the history
* also fix pat tests

Signed-off-by: Raghav Kaul <raghavkaul@google.com>
  • Loading branch information
raghavkaul authored May 10, 2023
1 parent 7736f36 commit 3d1c472
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions clients/githubrepo/branches_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {

Context("E2E TEST: Validate query cost", func() {
It("Should not have increased for HEAD query", func() {
skipIfTokenIsNot(patTokenType, "GITHUB_TOKEN only")
skipIfTokenIsNot(patTokenType, "PAT only")

repourl := &repoURL{
owner: "ossf",
Expand All @@ -49,7 +49,7 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {
})

It("Should fail for non-HEAD query", func() {
skipIfTokenIsNot(patTokenType, "GITHUB_TOKEN only")
skipIfTokenIsNot(patTokenType, "PAT only")

repourl := &repoURL{
owner: "ossf",
Expand All @@ -64,21 +64,24 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {

Context("E2E TEST: Get default branch", func() {
It("Should return the correct default branch", func() {
skipIfTokenIsNot(patTokenType, "GITHUB_TOKEN only")
skipIfTokenIsNot(patTokenType, "PAT only")

repourl := &repoURL{
owner: "ossf",
repo: "scorecard",
commitSHA: clients.HeadSHA,
}
brancheshandler.init(context.Background(), repourl)
Expect(brancheshandler.getDefaultBranch()).ShouldNot(BeNil())
Expect(brancheshandler.getDefaultBranch()).Should(Equal("main"))

branchRef, err := brancheshandler.getDefaultBranch()
Expect(err).Should(BeNil())
Expect(branchRef).ShouldNot(BeNil())
Expect(*branchRef.Name).Should(Equal("main"))
})
})
Context("E2E TEST: getBranch", func() {
It("Should return a branch", func() {
skipIfTokenIsNot(patTokenType, "GITHUB_TOKEN only")
skipIfTokenIsNot(patTokenType, "PAT only")

repourl := &repoURL{
owner: "ossf",
Expand All @@ -93,7 +96,7 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {
})

It("Should return an error for non-existent branch", func() {
skipIfTokenIsNot(patTokenType, "GITHUB_TOKEN only")
skipIfTokenIsNot(patTokenType, "PAT only")

repourl := &repoURL{
owner: "ossf",
Expand All @@ -103,13 +106,13 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {
brancheshandler.init(context.Background(), repourl)

branchRef, err := brancheshandler.getBranch("non-existent-branch")
Expect(err).ShouldNot(BeNil())
Expect(err).Should(BeNil())
Expect(branchRef).Should(BeNil())
})
})
Context("E2E TEST: query branch", func() {
It("Should return a branch", func() {
skipIfTokenIsNot(patTokenType, "GITHUB_TOKEN only")
skipIfTokenIsNot(patTokenType, "PAT only")

repourl := &repoURL{
owner: "ossf",
Expand All @@ -121,15 +124,18 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {
})

It("Should fail for non-HEAD query", func() {
skipIfTokenIsNot(patTokenType, "GITHUB_TOKEN only")
skipIfTokenIsNot(patTokenType, "PAT only")

repourl := &repoURL{
owner: "ossf",
repo: "scorecard",
commitSHA: "de5224bbc56eceb7a25aece55d2d53bbc561ed2d",
}
brancheshandler.init(context.Background(), repourl)
Expect(brancheshandler.query("main")).Should(BeNil())
branchRef, err := brancheshandler.query("main")

Expect(err).ShouldNot(BeNil())
Expect(branchRef).Should(BeNil())
})
})
})

0 comments on commit 3d1c472

Please sign in to comment.