MCPcopy Create free account
hub / github.com/conforma/cli / TestPopulateResultFromOutput

Function TestPopulateResultFromOutput

internal/validate/report_test.go:42–323  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40)
41
42func TestPopulateResultFromOutput(t *testing.T) {
43 tests := []struct {
44 name string
45 out *output.Output
46 err error
47 comp app.SnapshotComponent
48 showSuccesses bool
49 outputFormats []string
50 expectedResult Result
51 }{
52 {
53 name: "successful validation with output",
54 out: &output.Output{
55 ImageURL: "registry.com/image:tag",
56 PolicyInput: []byte("policy input"),
57 Signatures: []signature.EntitySignature{{KeyID: "key1"}},
58 },
59 err: nil,
60 comp: app.SnapshotComponent{
61 Name: "component1",
62 ContainerImage: "registry.com/image:tag",
63 },
64 showSuccesses: true,
65 outputFormats: []string{"json"},
66 expectedResult: Result{
67 Err: nil,
68 Component: applicationsnapshot.Component{
69 SnapshotComponent: app.SnapshotComponent{
70 Name: "component1",
71 ContainerImage: "registry.com/image:tag",
72 },
73 Success: true,
74 },
75 PolicyInput: []byte("policy input"),
76 },
77 },
78 {
79 name: "validation error",
80 out: nil,
81 err: errors.New("validation failed"),
82 comp: app.SnapshotComponent{
83 Name: "component1",
84 ContainerImage: "registry.com/image:tag",
85 },
86 showSuccesses: false,
87 outputFormats: []string{},
88 expectedResult: Result{
89 Err: errors.New("validation failed"),
90 Component: applicationsnapshot.Component{
91 SnapshotComponent: app.SnapshotComponent{
92 Name: "component1",
93 ContainerImage: "registry.com/image:tag",
94 },
95 Success: false,
96 },
97 },
98 },
99 {

Callers

nothing calls this directly

Calls 6

PopulateResultFromOutputFunction · 0.85
ContainsOutputFormatFunction · 0.85
ViolationsMethod · 0.80
SuccessesMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected