Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Korczynski <[email protected]>
  • Loading branch information
AdamKorcz committed Jan 30, 2024
1 parent b42e010 commit 4e85c1b
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions probes/pinsDependencies/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
)

func Test_Run(t *testing.T) {
jobName := "jobName"
msg := "msg"
t.Parallel()
//nolint:govet
tests := []struct {
Expand Down Expand Up @@ -492,6 +494,85 @@ func Test_Run(t *testing.T) {
},
err: sce.ErrScorecardInternal,
},
{
name: "dependency missing Location info",
raw: &checker.RawResults{
PinningDependenciesResults: checker.PinningDependenciesData{
Dependencies: []checker.Dependency{
{
Location: nil,
Msg: &msg,
Type: checker.DependencyUseTypeNpmCommand,
Pinned: asBoolPointer(true),
},
},
},
},
outcomes: []finding.Outcome{
finding.OutcomeNotApplicable,
},
},
{
name: "neither location nor msg is nil",
raw: &checker.RawResults{
PinningDependenciesResults: checker.PinningDependenciesData{
Dependencies: []checker.Dependency{
{
Location: &checker.File{},
Msg: &msg,
Type: checker.DependencyUseTypeNpmCommand,
Pinned: asBoolPointer(true),
},
},
},
},
outcomes: []finding.Outcome{
finding.OutcomeNotApplicable,
},
},
{
name: "pinned = nil",
raw: &checker.RawResults{
PinningDependenciesResults: checker.PinningDependenciesData{
Dependencies: []checker.Dependency{
{
Location: &checker.File{},
Msg: nil,
Type: checker.DependencyUseTypeNpmCommand,
Pinned: nil,
},
},
},
},
outcomes: []finding.Outcome{
finding.OutcomeNotApplicable,
},
},
{
name: "2 processing errors",
raw: &checker.RawResults{
PinningDependenciesResults: checker.PinningDependenciesData{
ProcessingErrors: []checker.ElementError{
{
Location: finding.Location{
Snippet: &jobName,
},
Err: sce.ErrJobOSParsing,
},
{
Location: finding.Location{
Snippet: &jobName,
},
Err: sce.ErrJobOSParsing,
},
},
},
},
outcomes: []finding.Outcome{
finding.OutcomeError,
finding.OutcomeError,
},
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
Expand Down

0 comments on commit 4e85c1b

Please sign in to comment.