MCPcopy
hub / github.com/aquasecurity/trivy / TestWriter_Write

Function TestWriter_Write

pkg/report/table/table_test.go:15–253  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestWriter_Write(t *testing.T) {
16 testCases := []struct {
17 name string
18 scanners types.Scanners
19 tableModes []types.TableMode
20 results types.Results
21 wantOutput string
22 includeNonFailures bool
23 }{
24 {
25 name: "vulnerability and custom resource",
26 scanners: types.Scanners{
27 types.VulnerabilityScanner,
28 },
29 tableModes: types.SupportedTableModes,
30 results: types.Results{
31 {
32 Target: "test",
33 Type: ftypes.Jar,
34 Class: types.ClassLangPkg,
35 Packages: []ftypes.Package{
36 {
37 Name: "foo",
38 Version: "1.2.3",
39 FilePath: "test.jar",
40 },
41 },
42 Vulnerabilities: []types.DetectedVulnerability{
43 {
44 VulnerabilityID: "CVE-2020-0001",
45 PkgName: "foo",
46 InstalledVersion: "1.2.3",
47 PrimaryURL: "https://avd.aquasec.com/nvd/cve-2020-0001",
48 Status: dbTypes.StatusWillNotFix,
49 PkgPath: "test.jar",
50 Vulnerability: dbTypes.Vulnerability{
51 Title: "foobar",
52 Description: "baz",
53 Severity: "HIGH",
54 },
55 },
56 },
57 CustomResources: []ftypes.CustomResource{
58 {
59 Type: "test",
60 Data: "test",
61 },
62 },
63 },
64 },
65 wantOutput: `
66Report Summary
67
68┌──────────┬──────┬─────────────────┐
69│ Target │ Type │ Vulnerabilities │
70├──────────┼──────┼─────────────────┤
71│ test.jar │ jar │ 1 │
72└──────────┴──────┴─────────────────┘

Callers

nothing calls this directly

Calls 6

WriteMethod · 0.95
NewWriterFunction · 0.92
ContextMethod · 0.80
EqualMethod · 0.80
StringMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…