Skip to content

Commit

Permalink
🌱 avoid assumptions about versions in tests (#4134)
Browse files Browse the repository at this point in the history
For example NixOS builds and tests scorecards in an environment that
sets the version, which would make this test fail as it currently
assumes the version is unset when running tests.

Signed-off-by: Arnout Engelen <arnout@bzzt.net>
  • Loading branch information
raboof committed May 30, 2024
1 parent 16ed8a6 commit 6b49140
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkg/scorecard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"sigs.k8s.io/release-utils/version"

"github.com/ossf/scorecard/v5/checker"
"github.com/ossf/scorecard/v5/clients"
Expand Down Expand Up @@ -128,6 +129,10 @@ func TestRunScorecard(t *testing.T) {
uri string
commitSHA string
}
// These values depend on the environment,
// so don't encode particular expectations
// in the test:
versionInfo := version.GetVersionInfo()
tests := []struct {
name string
args args
Expand All @@ -145,8 +150,8 @@ func TestRunScorecard(t *testing.T) {
Name: "github.com/ossf/scorecard",
},
Scorecard: ScorecardInfo{
Version: "devel",
CommitSHA: "unknown",
Version: versionInfo.GitVersion,
CommitSHA: versionInfo.GitCommit,
},
},
wantErr: false,
Expand Down Expand Up @@ -194,6 +199,10 @@ func TestRunScorecard(t *testing.T) {

func TestExperimentalRunProbes(t *testing.T) {
t.Parallel()
// These values depend on the environment,
// so don't encode particular expectations
// in the test:
versionInfo := version.GetVersionInfo()
type args struct {
uri string
commitSHA string
Expand Down Expand Up @@ -230,8 +239,8 @@ func TestExperimentalRunProbes(t *testing.T) {
},
},
Scorecard: ScorecardInfo{
Version: "devel",
CommitSHA: "unknown",
Version: versionInfo.GitVersion,
CommitSHA: versionInfo.GitCommit,
},
Findings: []finding.Finding{
{
Expand Down

0 comments on commit 6b49140

Please sign in to comment.