Debian Codegraph @

test/report_test.go

raw symbols SCIP
1 package testscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/
2
3 import (
4 "osscip-go gomod github.com/golang/go/src go1.16 os/"
5 "testingscip-go gomod github.com/golang/go/src go1.16 testing/"
6
7 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/"
8 )
9
10 func Test_new_simple_report_with_single_runscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/Test_new_simple_report_with_single_run().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
11 given, _, then := newReportTestscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/newReportTest().(t)
12
13 given.a_new_reportscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#a_new_report().().
14 with_a_run_addedscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#with_a_run_added().("tfsec", "https://tfsec.dev")
15 then.report_text_isscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#report_text_is().(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
16 }
17
18 func Test_new_report_with_empty_runscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/Test_new_report_with_empty_run().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
19 given, _, then := newReportTestscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/newReportTest().(t)
20
21 given.a_new_reportscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#a_new_report().().
22 with_a_run_with_empty_result_addedscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#with_a_run_with_empty_result_added().("tfsec", "https://tfsec.dev")
23 then.report_text_isscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#report_text_is().(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
24 }
25
26 func Test_new_simple_report_with_artifactscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/Test_new_simple_report_with_artifact().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
27 given, when, then := newReportTestscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/newReportTest().(t)
28
29 run := given.a_new_reportscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#a_new_report().().
30 with_a_run_addedscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#with_a_run_added().("tfsec", "https://tfsec.dev")
31 when.an_artifact_is_added_to_the_runscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#an_artifact_is_added_to_the_run().(run, "file://broken.go")
32 then.report_text_isscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#report_text_is().(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
33 }
34
35 func Test_new_simple_report_with_propertybagscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/Test_new_simple_report_with_propertybag().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
36 given, when, then := newReportTestscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/newReportTest().(t)
37
38 run := given.a_new_reportscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#a_new_report().().
39 with_a_run_addedscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#with_a_run_added().("tfsec", "https://tfsec.dev")
40 when.some_properties_are_added_to_the_runscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#some_properties_are_added_to_the_run().(run)
41 then.report_text_isscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#report_text_is().(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[],"properties":{"integer_property":10,"string_property":"this is a string"}}]}`)
42 }
43
44 func Test_new_simple_report_with_duplicate_artifactscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/Test_new_simple_report_with_duplicate_artifact().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
45 given, when, then := newReportTestscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/newReportTest().(t)
46
47 run := given.a_new_reportscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#a_new_report().().
48 with_a_run_addedscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#with_a_run_added().("tfsec", "https://tfsec.dev")
49 when.an_artifact_is_added_to_the_runscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#an_artifact_is_added_to_the_run().(run, "file://broken.go").
50 andscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#and().().
51 an_artifact_is_added_to_the_runscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#an_artifact_is_added_to_the_run().(run, "file://broken.go")
52 then.report_text_isscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#report_text_is().(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1},{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
53 }
54
55 func Test_load_sarif_from_stringscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/Test_load_sarif_from_string().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
56 given, _, then := newReportTestscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/newReportTest().(t)
57
58 content := `{
59 "version": "2.1.0",
60 "$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
61 "runs": [
62 {
63 "tool": {
64 "driver": {
65 "name": "ESLint",
66 "informationUri": "https://eslint.org"
67 }
68 }
69 }
70 ]
71 }`
72
73 given.a_report_is_loaded_from_a_stringscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#a_report_is_loaded_from_a_string().(content)
74 then.the_report_has_expected_driver_name_and_information_uriscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#the_report_has_expected_driver_name_and_information_uri().("ESLint", "https://eslint.org")
75 }
76
77 func Test_load_sarif_report_from_filescip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/Test_load_sarif_report_from_file().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
78 given, _, then := newReportTestscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/newReportTest().(t)
79
80 content := `{
81 "version": "2.1.0",
82 "$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
83 "runs": [
84 {
85 "tool": {
86 "driver": {
87 "name": "ESLint",
88 "informationUri": "https://eslint.org"
89 }
90 }
91 }
92 ]
93 }`
94
95 file, err := osscip-go gomod github.com/golang/go/src go1.16 os/.CreateTempscip-go gomod github.com/golang/go/src go1.16 os/CreateTemp().(t.TempDirscip-go gomod github.com/golang/go/src go1.16 testing/common#TempDir().(), "sarifReport")
96 assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NoError().(t, err)
97 defer file.Closescip-go gomod github.com/golang/go/src go1.16 os/File#Close().()
98
99 osscip-go gomod github.com/golang/go/src go1.16 os/.WriteFilescip-go gomod github.com/golang/go/src go1.16 os/WriteFile().(file.Namescip-go gomod github.com/golang/go/src go1.16 os/File#Name().(), []byte(content), 755)
100
101 given.a_report_is_loaded_from_a_filescip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#a_report_is_loaded_from_a_file().(file.Namescip-go gomod github.com/golang/go/src go1.16 os/File#Name().())
102 then.the_report_has_expected_driver_name_and_information_uriscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#the_report_has_expected_driver_name_and_information_uri().("ESLint", "https://eslint.org")
103 }
104
105 func Test_err_on_load_sarif_report_from_file_when_not_existsscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/Test_err_on_load_sarif_report_from_file_when_not_exists().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
106 given, _, _ := newReportTestscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/newReportTest().(t)
107 defer func() {
108 if err := recover().(error); err != nil {
109 assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/Equal().(t, "the provided file path doesn't have a file", err.Error())
110 }
111 }()
112 given.a_report_is_loaded_from_a_filescip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#a_report_is_loaded_from_a_file().("")
113 }
114
115 func Test_err_on_load_sarif_report_from_file_when_file_not_legitscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/Test_err_on_load_sarif_report_from_file_when_file_not_legit().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
116 given, _, _ := newReportTestscip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/newReportTest().(t)
117 defer func() {
118 if err := recover().(error); err != nil {
119 assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/Equal().(t, "the provided filepath could not be opened. read /tmp: is a directory", err.Error())
120 }
121 }()
122 given.a_report_is_loaded_from_a_filescip-go gomod github.com/owenrumney/go-sarif . `github.com/owenrumney/go-sarif/test`/reportTest#a_report_is_loaded_from_a_file().("/tmp")
123 }