diff --git a/checks/raw/dependency_update_tool_test.go b/checks/raw/dependency_update_tool_test.go new file mode 100644 index 00000000000..b1cd50a6bc8 --- /dev/null +++ b/checks/raw/dependency_update_tool_test.go @@ -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) + } + }) + } +}