From 614d7219af59083ec9f5de48bd7fb858b93c42d4 Mon Sep 17 00:00:00 2001 From: tran-the-lam Date: Thu, 1 Aug 2024 22:37:50 +0700 Subject: [PATCH] add ai testcase --- proposesolution/ai_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 proposesolution/ai_test.go diff --git a/proposesolution/ai_test.go b/proposesolution/ai_test.go new file mode 100644 index 0000000000..691f32b3b0 --- /dev/null +++ b/proposesolution/ai_test.go @@ -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") + } + } +}