Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Schrock <[email protected]>
  • Loading branch information
spencerschrock committed Dec 18, 2023
1 parent 1af3d24 commit 7ca9d1c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion app/server/verify_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,14 @@ func (s suffixStubTripper) RoundTrip(r *http.Request) (*http.Response, error) {
}, nil
}

func Test_githubVerifier_contains(t *testing.T) {
func Test_githubVerifier_contains_codeql_v1(t *testing.T) {
t.Parallel()
httpClient := http.Client{
Transport: suffixStubTripper{
responsePaths: map[string]string{
"codeql-action": "./testdata/api/github/repository.json", // api call which finds the default branch
"main...somehash": "./testdata/api/github/divergent.json", // doesnt belong to default branch
"v2...somehash": "./testdata/api/github/divergent.json", // doesnt belong to releases/v2 branch
"v1...somehash": "./testdata/api/github/containsCommit.json", // belongs to releases/v1 branch
},
},
Expand All @@ -140,6 +141,31 @@ func Test_githubVerifier_contains(t *testing.T) {
}
}

func Test_githubVerifier_contains_codeql_v2(t *testing.T) {
t.Parallel()
httpClient := http.Client{
Transport: suffixStubTripper{
responsePaths: map[string]string{
"codeql-action": "./testdata/api/github/repository.json", // api call which finds the default branch
"main...somehash": "./testdata/api/github/divergent.json", // doesnt belong to default branch
"v2...somehash": "./testdata/api/github/containsCommit.json", // belongs to releases/v2 branch
},
},
}
client := github.NewClient(&httpClient)
gv := githubVerifier{
ctx: context.Background(),
client: client,
}
got, err := gv.contains("github", "codeql-action", "somehash")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if got != true {
t.Errorf("expected to contain hash, but it didnt")
}
}

func FuzzVerifyWorkflow(f *testing.F) {
testfiles := []string{
"testdata/workflow-valid.yml",
Expand Down

0 comments on commit 7ca9d1c

Please sign in to comment.