Skip to content

Commit

Permalink
✨ Unit tests for dependency update
Browse files Browse the repository at this point in the history
Unit tests for dependency update.

#986

Signed-off-by: naveen <[email protected]>
  • Loading branch information
naveensrinivasan committed Jan 19, 2022
1 parent 96ea22e commit 9973bde
Showing 1 changed file with 124 additions and 0 deletions.
124 changes: 124 additions & 0 deletions checks/raw/dependency_update_tool_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Copyright 2020 Security Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package raw

import (
"testing"

"github.com/ossf/scorecard/v4/checker"
)

func Test_checkDependencyFileExists(t *testing.T) {
t.Parallel()
//nolint
type args struct {
name string
data *[]checker.Tool
}
//nolint
tests := []struct {
name string
args args
want bool
wantErr bool
}{
{
name: "check dependency file exists",
args: args{
name: ".github/dependabot.yml",
data: &[]checker.Tool{},
},
want: false,
wantErr: false,
},
{
name: ".other",
args: args{
name: ".other",
data: &[]checker.Tool{},
},
want: true,
wantErr: false,
},
{
name: ".github/renovate.json",
args: args{
name: ".github/renovate.json",
data: &[]checker.Tool{},
},
want: false,
wantErr: false,
},
{
name: ".github/renovate.json5",
args: args{
name: ".github/renovate.json5",
data: &[]checker.Tool{},
},
want: false,
wantErr: false,
},
{
name: ".renovaterc.json",
args: args{
name: ".renovaterc.json",
data: &[]checker.Tool{},
},
want: false,
wantErr: false,
},
{
name: "renovate.json",
args: args{
name: "renovate.json",
data: &[]checker.Tool{},
},
want: false,
wantErr: false,
},
{
name: "renovate.json5",
args: args{
name: "renovate.json5",
data: &[]checker.Tool{},
},
want: false,
wantErr: false,
},
{
name: ".renovaterc",
args: args{
name: ".renovaterc",
data: &[]checker.Tool{},
},
want: false,
wantErr: false,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := checkDependencyFileExists(tt.args.name, tt.args.data)
if (err != nil) != tt.wantErr {
t.Errorf("checkDependencyFileExists() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("checkDependencyFileExists() = %v, want %v for test %v", got, tt.want, tt.name)
}
})
}
}

0 comments on commit 9973bde

Please sign in to comment.