Skip to content

Commit 9973bde

Browse files
✨ Unit tests for dependency update
Unit tests for dependency update. #986 Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
1 parent 96ea22e commit 9973bde

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// Copyright 2020 Security Scorecard Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package raw
16+
17+
import (
18+
"testing"
19+
20+
"github.com/ossf/scorecard/v4/checker"
21+
)
22+
23+
func Test_checkDependencyFileExists(t *testing.T) {
24+
t.Parallel()
25+
//nolint
26+
type args struct {
27+
name string
28+
data *[]checker.Tool
29+
}
30+
//nolint
31+
tests := []struct {
32+
name string
33+
args args
34+
want bool
35+
wantErr bool
36+
}{
37+
{
38+
name: "check dependency file exists",
39+
args: args{
40+
name: ".github/dependabot.yml",
41+
data: &[]checker.Tool{},
42+
},
43+
want: false,
44+
wantErr: false,
45+
},
46+
{
47+
name: ".other",
48+
args: args{
49+
name: ".other",
50+
data: &[]checker.Tool{},
51+
},
52+
want: true,
53+
wantErr: false,
54+
},
55+
{
56+
name: ".github/renovate.json",
57+
args: args{
58+
name: ".github/renovate.json",
59+
data: &[]checker.Tool{},
60+
},
61+
want: false,
62+
wantErr: false,
63+
},
64+
{
65+
name: ".github/renovate.json5",
66+
args: args{
67+
name: ".github/renovate.json5",
68+
data: &[]checker.Tool{},
69+
},
70+
want: false,
71+
wantErr: false,
72+
},
73+
{
74+
name: ".renovaterc.json",
75+
args: args{
76+
name: ".renovaterc.json",
77+
data: &[]checker.Tool{},
78+
},
79+
want: false,
80+
wantErr: false,
81+
},
82+
{
83+
name: "renovate.json",
84+
args: args{
85+
name: "renovate.json",
86+
data: &[]checker.Tool{},
87+
},
88+
want: false,
89+
wantErr: false,
90+
},
91+
{
92+
name: "renovate.json5",
93+
args: args{
94+
name: "renovate.json5",
95+
data: &[]checker.Tool{},
96+
},
97+
want: false,
98+
wantErr: false,
99+
},
100+
{
101+
name: ".renovaterc",
102+
args: args{
103+
name: ".renovaterc",
104+
data: &[]checker.Tool{},
105+
},
106+
want: false,
107+
wantErr: false,
108+
},
109+
}
110+
for _, tt := range tests {
111+
tt := tt
112+
t.Run(tt.name, func(t *testing.T) {
113+
t.Parallel()
114+
got, err := checkDependencyFileExists(tt.args.name, tt.args.data)
115+
if (err != nil) != tt.wantErr {
116+
t.Errorf("checkDependencyFileExists() error = %v, wantErr %v", err, tt.wantErr)
117+
return
118+
}
119+
if got != tt.want {
120+
t.Errorf("checkDependencyFileExists() = %v, want %v for test %v", got, tt.want, tt.name)
121+
}
122+
})
123+
}
124+
}

0 commit comments

Comments
 (0)