MCPcopy
hub / github.com/yannh/kubeconform / TestJSONWrite

Function TestJSONWrite

pkg/output/json_test.go:11–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestJSONWrite(t *testing.T) {
12 for _, testCase := range []struct {
13 name string
14 withSummary bool
15 isStdin bool
16 verbose bool
17 results []validator.Result
18 expect string
19 }{
20 {
21 "a single deployment, no summary, no verbose",
22 false,
23 false,
24 false,
25 []validator.Result{},
26 "{\n \"resources\": []\n}\n",
27 },
28
29 {
30 "a single deployment, summary, no verbose",
31 true,
32 false,
33 false,
34 []validator.Result{
35 {
36 Resource: resource.Resource{
37 Path: "deployment.yml",
38 Bytes: []byte(`apiVersion: apps/v1
39kind: Deployment
40metadata:
41 name: "my-app"
42`),
43 },
44 Status: validator.Valid,
45 Err: nil,
46 },
47 },
48 `{
49 "resources": [],
50 "summary": {
51 "valid": 1,
52 "invalid": 0,
53 "errors": 0,
54 "skipped": 0
55 }
56}
57`,
58 },
59 {
60 "a single deployment, verbose, with summary",
61 true,
62 false,
63 true,
64 []validator.Result{
65 {
66 Resource: resource.Resource{
67 Path: "deployment.yml",
68 Bytes: []byte(`apiVersion: apps/v1

Callers

nothing calls this directly

Calls 4

jsonOutputFunction · 0.85
WriteMethod · 0.65
FlushMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected