Skip to content

Commit

Permalink
replace unneeded t.Errorf
Browse files Browse the repository at this point in the history
Signed-off-by: Ramon Petgrave <[email protected]>
  • Loading branch information
ramonpetgrave64 committed Oct 7, 2024
1 parent 1dbee04 commit b7eef8c
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 71 deletions.
4 changes: 2 additions & 2 deletions cli/slsa-verifier/main_regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {

outBuilderID, err := cmd.Exec(context.Background(), []string{image})
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}

if err != nil {
Expand Down Expand Up @@ -1332,7 +1332,7 @@ func Test_runVerifyGCBArtifactImage(t *testing.T) {
outBuilderID, err := cmd.Exec(context.Background(), []string{image})

if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}

if err != nil {
Expand Down
26 changes: 13 additions & 13 deletions verifiers/internal/gcb/provenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func Test_VerifyBuilder(t *testing.T) {
}
outBuilderID, err := prov.VerifyBuilder(&builderOpts)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}

if err != nil {
Expand Down Expand Up @@ -313,7 +313,7 @@ func Test_validateBuildType(t *testing.T) {
}
err = validateBuildType(*builderID, tt.buildType)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -579,7 +579,7 @@ func Test_VerifySourceURI(t *testing.T) {
}
err = prov.VerifySourceURI(tt.source, *builderID)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -704,7 +704,7 @@ func Test_VerifySignature(t *testing.T) {

err = prov.VerifySignature()
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -745,7 +745,7 @@ func Test_ProvenanceFromBytes(t *testing.T) {

_, err = ProvenanceFromBytes(content)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -810,7 +810,7 @@ func Test_VerifySubjectDigest(t *testing.T) {

err = prov.VerifySubjectDigest(tt.hash)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -889,7 +889,7 @@ func Test_VerifySummary(t *testing.T) {
}
err = prov.VerifySummary(&provenanceOpts)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -970,7 +970,7 @@ func Test_VerifyMetadata(t *testing.T) {
}
err = prov.VerifyMetadata(&provenanceOpts)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -1038,7 +1038,7 @@ func Test_VerifyTextProvenance(t *testing.T) {
if !tt.alter {
err = prov.VerifyTextProvenance()
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
return
}
Expand Down Expand Up @@ -1110,7 +1110,7 @@ func Test_VerifyTextProvenance(t *testing.T) {

err = prov.VerifyTextProvenance()
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
// Start with the original string value.
patch = []byte(strings.Clone(string(cpy)))
Expand Down Expand Up @@ -1184,7 +1184,7 @@ func Test_VerifyBranch(t *testing.T) {

err = prov.VerifyBranch(tt.branch)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -1297,7 +1297,7 @@ func Test_VerifyTag(t *testing.T) {

err = prov.VerifyTag(tt.tag)
if !cmp.Equal(err, tt.err, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -1496,7 +1496,7 @@ func Test_VerifyVersionedTag(t *testing.T) {

err = prov.VerifyVersionedTag(tt.tag)
if !cmp.Equal(err, tt.err, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions verifiers/internal/gcb/slsaprovenance/v0.1/provenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func Test_New(t *testing.T) {
fmt.Println(string(content))
_, err = New(content)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -107,10 +107,10 @@ func Test_getSubstitutionsField(t *testing.T) {

value, err := getSubstitutionsField(internalParemeters, tt.field)
if !cmp.Equal(err, tt.err, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
if err == nil && !cmp.Equal(value, tt.value) {
t.Errorf(cmp.Diff(value, tt.value))
t.Error(cmp.Diff(value, tt.value))
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions verifiers/internal/gcb/slsaprovenance/v1.0/provenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func Test_getSubstitutionsField(t *testing.T) {

value, err := getSubstitutionsField(internalParemeters, tt.field)
if !cmp.Equal(err, tt.err, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
if err == nil && !cmp.Equal(value, tt.value) {
t.Errorf(cmp.Diff(value, tt.value))
t.Error(cmp.Diff(value, tt.value))
}
})
}
Expand Down
12 changes: 6 additions & 6 deletions verifiers/internal/gha/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func Test_isTrustedDelegatorBuilder(t *testing.T) {

res := isTrustedDelegatorBuilder(trustedBuilderID, tt.trustedBuilderIDs)
if res != tt.result {
t.Errorf(cmp.Diff(res, tt.result))
t.Error(cmp.Diff(res, tt.result))
}
})
}
Expand Down Expand Up @@ -442,7 +442,7 @@ func Test_VerifyCertficateSourceRepository(t *testing.T) {
t.Parallel()
err := VerifyCertficateSourceRepository(tt.workflow, tt.source)
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -611,7 +611,7 @@ func Test_verifyTrustedBuilderID(t *testing.T) {
t.Parallel()
id, byob, err := verifyTrustedBuilderID(httpsGithubCom+tt.path, tt.tag, tt.id, tt.defaults)
if byob != tt.byob {
t.Errorf(cmp.Diff(byob, tt.byob))
t.Error(cmp.Diff(byob, tt.byob))
}
if diff := cmp.Diff(tt.err, err, cmpopts.EquateErrors()); diff != "" {
t.Fatalf("unexpected error (-want +got):\n%s", diff)
Expand Down Expand Up @@ -817,7 +817,7 @@ func Test_verifyTrustedBuilderRef(t *testing.T) {

err := verifyTrustedBuilderRef(&wf, tt.builderRef)
if !errCmp(err, tt.expected) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -1267,14 +1267,14 @@ func Test_GetWorkflowInfoFromCertificate(t *testing.T) {
t.Parallel()
workflow, err := GetWorkflowInfoFromCertificate(&tt.cert)
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
if err != nil {
return
}

if !cmp.Equal(*workflow, tt.workflow) {
t.Errorf(cmp.Diff(*workflow, tt.workflow))
t.Error(cmp.Diff(*workflow, tt.workflow))
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion verifiers/internal/gha/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func Test_verifyBundle(t *testing.T) {
_, err = VerifyProvenanceBundle(ctx, content, trustedRoot)

if !errCmp(err, tt.expected) {
t.Errorf(cmp.Diff(err, tt.expected))
t.Error(cmp.Diff(err, tt.expected))
}
})
}
Expand Down
18 changes: 9 additions & 9 deletions verifiers/internal/gha/npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Test_verifyName(t *testing.T) {
err := verifyName(tt.actual, tt.expected)

if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.expected))
t.Error(cmp.Diff(err, tt.expected))
}
})
}
Expand Down Expand Up @@ -425,7 +425,7 @@ func Test_verifyPublishSubjectName(t *testing.T) {
err := verifyPublishSubjectName(tt.att, tt.subject)

if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
t.Error(cmp.Diff(err, tt.err))
}
})
}
Expand Down Expand Up @@ -491,7 +491,7 @@ func Test_verifyPublishPredicateName(t *testing.T) {
err := verifyPublishPredicateName(tt.att, tt.subject)

if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
t.Error(cmp.Diff(err, tt.err))
}
})
}
Expand Down Expand Up @@ -568,7 +568,7 @@ func Test_verifyPublishPredicateVersion(t *testing.T) {
err := verifyPublishPredicateVersion(tt.att, tt.version)

if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
t.Error(cmp.Diff(err, tt.err))
}
})
}
Expand Down Expand Up @@ -792,7 +792,7 @@ func Test_verifyPackageName(t *testing.T) {

err = npm.verifyPackageName(&tt.subject)
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
t.Error(cmp.Diff(err, tt.err))
}
})
}
Expand Down Expand Up @@ -869,7 +869,7 @@ func Test_verifyPublishAttestationSubjectDigest(t *testing.T) {

err = npm.verifyPublishAttestationSubjectDigest(tt.hash)
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
t.Error(cmp.Diff(err, tt.err))
}
})
}
Expand Down Expand Up @@ -951,7 +951,7 @@ func Test_verifyPackageVersion(t *testing.T) {

err = npm.verifyPackageVersion(&tt.version)
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
t.Error(cmp.Diff(err, tt.err))
}
})
}
Expand Down Expand Up @@ -1060,7 +1060,7 @@ func Test_verifyIntotoTypes(t *testing.T) {

err := verifyIntotoTypes(tt.att, tt.predicateTypes, tt.payloadType, tt.prefix)
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
t.Error(cmp.Diff(err, tt.err))
}
})
}
Expand Down Expand Up @@ -1148,7 +1148,7 @@ func Test_verifyIntotoHeaders(t *testing.T) {

err = npm.verifyIntotoHeaders()
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
t.Error(cmp.Diff(err, tt.err))
}
})
}
Expand Down
Loading

0 comments on commit b7eef8c

Please sign in to comment.