forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitlab_sast_test.go
41 lines (37 loc) · 1.06 KB
/
gitlab_sast_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package report
import (
"fmt"
"os"
"path/filepath"
"testing"
"github.com/Checkmarx/kics/pkg/model"
"github.com/Checkmarx/kics/test"
"github.com/stretchr/testify/require"
)
var gitlabSASTTests = []struct {
caseTest jsonCaseTest
expectedResult model.Summary
}{
{
caseTest: jsonCaseTest{
summary: test.SummaryMock,
path: "./testdir",
filename: "test",
},
expectedResult: test.SummaryMock,
},
}
// TestPrintGitlabSASTReport tests the functions [PrintGitlabSASTReport()] and all the methods called by them
func TestPrintGitlabSASTReport(t *testing.T) {
for idx, test := range gitlabSASTTests {
t.Run(fmt.Sprintf("Gitlab SAST Report File test case %d", idx), func(t *testing.T) {
if err := os.MkdirAll(test.caseTest.path, os.ModePerm); err != nil {
t.Fatal(err)
}
err := PrintGitlabSASTReport(test.caseTest.path, test.caseTest.filename, test.caseTest.summary)
require.NoError(t, err)
require.FileExists(t, filepath.Join(test.caseTest.path, "gl-sast-"+test.caseTest.filename+".json"))
os.RemoveAll(test.caseTest.path)
})
}
}