Skip to content

Commit

Permalink
🌱 Improve e2e workflow tests (#3282)
Browse files Browse the repository at this point in the history
- Ensure that only head queries are supported in workflow tests
- Add a test to detect when a non-existent workflow file is used

[e2e/workflow_test.go]
- Add a test to check that only head queries are supported
- Add a test to check that a non-existent workflow file returns an error

Signed-off-by: naveensrinivasan <[email protected]>
  • Loading branch information
naveensrinivasan committed Jul 21, 2023
1 parent be7c032 commit 32e11dc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions e2e/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,29 @@ var _ = Describe("E2E TEST:WorkflowRun", func() {
Expect(err).Should(BeNil())
Expect(len(runs)).Should(BeNumerically(">", 0))
})
It("Should should fail because only head queries are supported", func() {
// using the scorecard repo as an example. The tests repo workflow won't have any runs in the future and
// that is why we are using the scorecard repo.
repo, err := githubrepo.MakeGithubRepo("ossf/scorecard")
Expect(err).Should(BeNil())
repoClient := githubrepo.CreateGithubRepoClient(context.Background(), logger)
err = repoClient.InitRepo(repo, "123456789", 0)
Expect(err).Should(BeNil())
runs, err := repoClient.ListSuccessfulWorkflowRuns("scorecard-analysis.yml")
Expect(err).ShouldNot(BeNil())
Expect(len(runs)).Should(BeNumerically("==", 0))
})
It("Should should fail the workflow file doesn't exist", func() {
// using the scorecard repo as an example. The tests repo workflow won't have any runs in the future and
// that is why we are using the scorecard repo.
repo, err := githubrepo.MakeGithubRepo("ossf/scorecard")
Expect(err).Should(BeNil())
repoClient := githubrepo.CreateGithubRepoClient(context.Background(), logger)
err = repoClient.InitRepo(repo, clients.HeadSHA, 0)
Expect(err).Should(BeNil())
runs, err := repoClient.ListSuccessfulWorkflowRuns("non-existing.yml")
Expect(err).ShouldNot(BeNil())
Expect(len(runs)).Should(BeNumerically("==", 0))
})
})
})

0 comments on commit 32e11dc

Please sign in to comment.