(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestCodeScanningService_UploadSarif(t *testing.T) { |
| 58 | t.Parallel() |
| 59 | client, mux, _ := setup(t) |
| 60 | |
| 61 | expectedSarifID := &SarifID{ |
| 62 | ID: Ptr("testid"), |
| 63 | URL: Ptr("https://example.com/testurl"), |
| 64 | } |
| 65 | |
| 66 | sarifAnalysis := &SarifAnalysis{CommitSHA: Ptr("abc"), Ref: Ptr("ref/head/main"), Sarif: Ptr("abc"), CheckoutURI: Ptr("uri"), StartedAt: &Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}, ToolName: Ptr("codeql-cli")} |
| 67 | |
| 68 | mux.HandleFunc("/repos/o/r/code-scanning/sarifs", func(w http.ResponseWriter, r *http.Request) { |
| 69 | testMethod(t, r, "POST") |
| 70 | testJSONBody(t, r, sarifAnalysis) |
| 71 | w.WriteHeader(http.StatusAccepted) |
| 72 | respBody, _ := json.Marshal(expectedSarifID) |
| 73 | _, _ = w.Write(respBody) |
| 74 | }) |
| 75 | |
| 76 | ctx := t.Context() |
| 77 | respSarifID, _, err := client.CodeScanning.UploadSarif(ctx, "o", "r", sarifAnalysis) |
| 78 | if err != nil { |
| 79 | t.Errorf("CodeScanning.UploadSarif returned error: %v", err) |
| 80 | } |
| 81 | if !cmp.Equal(expectedSarifID, respSarifID) { |
| 82 | t.Errorf("Sarif response = %+v, want %+v", respSarifID, expectedSarifID) |
| 83 | } |
| 84 | |
| 85 | const methodName = "UploadSarif" |
| 86 | testBadOptions(t, methodName, func() (err error) { |
| 87 | _, _, err = client.CodeScanning.UploadSarif(ctx, "\n", "\n", sarifAnalysis) |
| 88 | return err |
| 89 | }) |
| 90 | |
| 91 | testNewRequestAndDoFailureCategory(t, methodName, client, CodeScanningUploadCategory, func() (*Response, error) { |
| 92 | _, resp, err := client.CodeScanning.UploadSarif(ctx, "o", "r", sarifAnalysis) |
| 93 | return resp, err |
| 94 | }) |
| 95 | } |
| 96 | |
| 97 | func TestCodeScanningService_GetSARIF(t *testing.T) { |
| 98 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…