MCPcopy
hub / github.com/ossf/scorecard / TestJSONOutput

Function TestJSONOutput

cron/internal/format/json_test.go:70–491  ·  view source on GitHub ↗

nolint:gocognit

(t *testing.T)

Source from the content-addressed store, hash-verified

68
69//nolint:gocognit
70func TestJSONOutput(t *testing.T) {
71 t.Parallel()
72
73 repoCommit := "68bc59901773ab4c051dfcea0cc4201a1567ab32"
74 scorecardCommit := "ccbc59901773ab4c051dfcea0cc4201a1567abdd"
75 scorecardVersion := "1.2.3"
76 repoName := "org/name"
77 date, e := time.Parse("2006-01-02", "2021-08-25")
78 if e != nil {
79 panic(fmt.Errorf("time.Parse: %w", e))
80 }
81
82 checkDocs := jsonMockDocRead()
83 //nolint:govet
84 tests := []struct {
85 name string
86 expected string
87 showDetails bool
88 logLevel log.Level
89 result scorecard.Result
90 }{
91 {
92 name: "check-1",
93 showDetails: true,
94 expected: "./testdata/check1.json",
95 logLevel: log.DebugLevel,
96 result: scorecard.Result{
97 Repo: scorecard.RepoInfo{
98 Name: repoName,
99 CommitSHA: repoCommit,
100 },
101 Scorecard: scorecard.ScorecardInfo{
102 Version: scorecardVersion,
103 CommitSHA: scorecardCommit,
104 },
105 Date: date,
106 Checks: []checker.CheckResult{
107 {
108 Details: []checker.CheckDetail{
109 {
110 Type: checker.DetailWarn,
111 Msg: checker.LogMessage{
112 Text: "warn message",
113 Path: "src/file1.cpp",
114 Type: finding.FileTypeSource,
115 Offset: 5,
116 Snippet: "if (bad) {BUG();}",
117 },
118 },
119 },
120 Score: 5,
121 Reason: "half score reason",
122 Name: "Check-Name",
123 },
124 },
125 Metadata: []string{},
126 },
127 },

Callers

nothing calls this directly

Calls 6

AsJSON2Function · 0.85
WriteMethod · 0.80
ValidateMethod · 0.80
jsonMockDocReadFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected