Skip to content

Commit

Permalink
add ai testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
tran-the-lam committed Aug 1, 2024
1 parent 75a7f41 commit 614d721
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions proposesolution/ai_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package proposesolution_test

import (
"testing"

"github.com/securego/gosec/v2/issue"
"github.com/securego/gosec/v2/proposesolution"
)

func TestGenerateSolution(t *testing.T) {
aiApiProvider := proposesolution.GeminiProvider
aiApiKey := "test-api-key" // Replace with a valid API key for actual testing

issues := []*issue.Issue{
{
What: "Blocklisted import crypto/md5: weak cryptographic primitive",
},
}

err := proposesolution.GenerateSolution(aiApiProvider, aiApiKey, issues)
if err != nil {
t.Fatalf("Expected no error, got %v", err)
}

for _, issue := range issues {
if issue.ProposedSolution == "" {
t.Errorf("Expected a proposed solution, got an empty string")
}
}
}

0 comments on commit 614d721

Please sign in to comment.