Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Korczynski <[email protected]>
  • Loading branch information
AdamKorcz committed Dec 4, 2023
1 parent 0b8d614 commit 2033d28
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 62 deletions.
97 changes: 48 additions & 49 deletions checks/evaluation/ci_tests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,104 +25,103 @@ import (
// add a unit test to the probes with the same findings.
func TestCITests(t *testing.T) {
t.Parallel()
//nolint
tests := []struct {
name string
findings []finding.Finding
result scut.TestReturn
findings []finding.Finding
result scut.TestReturn
}{
{
name: "Has CI tests. 1 tested out of 1 merged",
findings: []finding.Finding {
findings: []finding.Finding{
{
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 1, "totalTested": 1},
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 1, "totalTested": 1},
Location: &finding.Location{Type: 4},
},
},
result: scut.TestReturn{
Score: 10,
NumberOfInfo: 1,
Score: 10,
NumberOfInfo: 1,
},
},
{
name: "Has CI tests. 3 tested out of 4 merged",
findings: []finding.Finding {
findings: []finding.Finding{
{
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 4, "totalTested": 3},
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 4, "totalTested": 3},
Location: &finding.Location{Type: 4},
},
{
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 4, "totalTested": 3},
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 4, "totalTested": 3},
Location: &finding.Location{Type: 4},
},
{
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 4, "totalTested": 3},
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 4, "totalTested": 3},
Location: &finding.Location{Type: 4},
},
},
result: scut.TestReturn{
Score: 7,
NumberOfInfo: 3,
Score: 7,
NumberOfInfo: 3,
},
},
{
name: "More tested than there are findings = error",
findings: []finding.Finding {
findings: []finding.Finding{
{
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 2, "totalTested": 2},
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 2, "totalTested": 2},
Location: &finding.Location{Type: 4},
},
},
result: scut.TestReturn{
Error: sce.ErrScorecardInternal,
NumberOfInfo: 0,
Score: -1,
Error: sce.ErrScorecardInternal,
NumberOfInfo: 0,
Score: -1,
},
},
{
name: "More tested than merged = error",
findings: []finding.Finding {
findings: []finding.Finding{
{
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 2, "totalTested": 3},
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 2, "totalTested": 3},
Location: &finding.Location{Type: 4},
},
{
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 2, "totalTested": 3},
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 2, "totalTested": 3},
Location: &finding.Location{Type: 4},
},
{
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 2, "totalTested": 3},
Outcome: finding.OutcomePositive,
Probe: "testsRunInCI",
Message: "CI test found: pr: 1, context: e2e",
Values: map[string]int{"totalMerged": 2, "totalTested": 3},
Location: &finding.Location{Type: 4},
},
},
result: scut.TestReturn{
Error: sce.ErrScorecardInternal,
NumberOfInfo: 0,
Score: -1,
Error: sce.ErrScorecardInternal,
NumberOfInfo: 0,
Score: -1,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion probes/testsRunInCI/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// nolint:stylecheck
//nolint:stylecheck
package testsRunInCI

import (
Expand Down
22 changes: 10 additions & 12 deletions probes/testsRunInCI/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// nolint:stylecheck
//nolint:stylecheck
package testsRunInCI

import (
Expand All @@ -37,7 +37,7 @@ const (
// values of the findings are important to the probe.
func Test_Run(t *testing.T) {
t.Parallel()
// nolint:govet
//nolint:govet
tests := []struct {
name string
raw *checker.RawResults
Expand Down Expand Up @@ -255,8 +255,6 @@ func Test_isTest(t *testing.T) {
func Test_prHasSuccessfulCheck(t *testing.T) {
t.Parallel()

//enabled nolint because this is a test
//nolint
tests := []struct {
name string
args checker.RevisionCIInfo
Expand Down Expand Up @@ -328,10 +326,10 @@ func Test_prHasSuccessfulCheck(t *testing.T) {

func Test_prHasSuccessStatus(t *testing.T) {
t.Parallel()
type args struct { //nolint:govet
type args struct {
r checker.RevisionCIInfo
}
tests := []struct { //nolint:govet
tests := []struct {
name string
args args
want bool
Expand Down Expand Up @@ -385,13 +383,13 @@ func Test_prHasSuccessStatus(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, _, err := prHasSuccessStatus(tt.args.r) //nolint:govet
if (err != nil) != tt.wantErr { //nolint:govet
t.Errorf("prHasSuccessStatus() error = %v, wantErr %v", err, tt.wantErr) //nolint:govet
got, _, err := prHasSuccessStatus(tt.args.r)
if (err != nil) != tt.wantErr {
t.Errorf("prHasSuccessStatus() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want { //nolint:govet
t.Errorf("prHasSuccessStatus() got = %v, want %v", got, tt.want) //nolint:govet
if got != tt.want {
t.Errorf("prHasSuccessStatus() got = %v, want %v", got, tt.want)
}
})
}
Expand Down Expand Up @@ -482,7 +480,7 @@ func Test_prHasSuccessfulCheckAdditional(t *testing.T) {
t.Errorf("prHasSuccessfulCheck() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want { //nolint:govet
if got != tt.want {
t.Errorf("prHasSuccessfulCheck() got = %v, want %v", got, tt.want)
}
})
Expand Down

0 comments on commit 2033d28

Please sign in to comment.