Skip to content

Commit

Permalink
Merge pull request #617 from Security-Onion-Solutions/cogburn/fix-test
Browse files Browse the repository at this point in the history
Fix TestRefreshAiSummaries Intermittent Failures
  • Loading branch information
coreyogburn authored Aug 19, 2024
2 parents 63f47a9 + 6ecc8a9 commit 3c4c5aa
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions server/modules/detections/ai_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package detections

import (
"io/fs"
"sort"
"testing"

"github.com/apex/log"
Expand All @@ -13,7 +14,6 @@ import (
)

func TestRefreshAiSummaries(t *testing.T) {
t.Skip("Intermittently failing. See build-soc job #31.")
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand All @@ -28,17 +28,30 @@ func TestRefreshAiSummaries(t *testing.T) {
iom.EXPECT().ReadDir("baseRepoFolder").Return([]fs.DirEntry{}, nil)
iom.EXPECT().CloneRepo(gomock.Any(), "baseRepoFolder/repo1", repo, &branch).Return(nil)
iom.EXPECT().ReadFile("baseRepoFolder/repo1/detections-ai/sigma_summaries.yaml").Return([]byte(summaries), nil)
loader.EXPECT().LoadAuxiliaryData([]*model.AiSummary{
{
PublicId: "87e55c67-46f0-4a7b-a3c6-d473ab7e8392",
Summary: "ai text goes here",
},
{
PublicId: "a23077fc-a5ef-427f-92ab-d3de7f56834d",
Reviewed: true,
Summary: "ai text goes here",
},
}).Return(nil)
loader.EXPECT().LoadAuxiliaryData(gomock.Any()).DoAndReturn(func(sums []*model.AiSummary) error {
expected := []*model.AiSummary{
{
PublicId: "87e55c67-46f0-4a7b-a3c6-d473ab7e8392",
Summary: "ai text goes here",
},
{
PublicId: "a23077fc-a5ef-427f-92ab-d3de7f56834d",
Reviewed: true,
Summary: "ai text goes here",
},
}

sort.Slice(sums, func(i, j int) bool {
return sums[i].PublicId < sums[j].PublicId
})

assert.Equal(t, len(expected), len(sums))
for i := range sums {
assert.Equal(t, *expected[i], *sums[i])
}

return nil
})

logger := log.WithField("test", true)

Expand Down

0 comments on commit 3c4c5aa

Please sign in to comment.