mirror of
https://github.com/ossf/scorecard.git
synced 2024-10-26 18:39:11 +03:00
🌱 avoid assumptions about versions in tests (#4134)
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>
This commit is contained in:
parent
16ed8a68aa
commit
6b49140bbf
@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
|
"sigs.k8s.io/release-utils/version"
|
||||||
|
|
||||||
"github.com/ossf/scorecard/v5/checker"
|
"github.com/ossf/scorecard/v5/checker"
|
||||||
"github.com/ossf/scorecard/v5/clients"
|
"github.com/ossf/scorecard/v5/clients"
|
||||||
@ -128,6 +129,10 @@ func TestRunScorecard(t *testing.T) {
|
|||||||
uri string
|
uri string
|
||||||
commitSHA string
|
commitSHA string
|
||||||
}
|
}
|
||||||
|
// These values depend on the environment,
|
||||||
|
// so don't encode particular expectations
|
||||||
|
// in the test:
|
||||||
|
versionInfo := version.GetVersionInfo()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
args args
|
args args
|
||||||
@ -145,8 +150,8 @@ func TestRunScorecard(t *testing.T) {
|
|||||||
Name: "github.com/ossf/scorecard",
|
Name: "github.com/ossf/scorecard",
|
||||||
},
|
},
|
||||||
Scorecard: ScorecardInfo{
|
Scorecard: ScorecardInfo{
|
||||||
Version: "devel",
|
Version: versionInfo.GitVersion,
|
||||||
CommitSHA: "unknown",
|
CommitSHA: versionInfo.GitCommit,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
@ -194,6 +199,10 @@ func TestRunScorecard(t *testing.T) {
|
|||||||
|
|
||||||
func TestExperimentalRunProbes(t *testing.T) {
|
func TestExperimentalRunProbes(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
// These values depend on the environment,
|
||||||
|
// so don't encode particular expectations
|
||||||
|
// in the test:
|
||||||
|
versionInfo := version.GetVersionInfo()
|
||||||
type args struct {
|
type args struct {
|
||||||
uri string
|
uri string
|
||||||
commitSHA string
|
commitSHA string
|
||||||
@ -230,8 +239,8 @@ func TestExperimentalRunProbes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Scorecard: ScorecardInfo{
|
Scorecard: ScorecardInfo{
|
||||||
Version: "devel",
|
Version: versionInfo.GitVersion,
|
||||||
CommitSHA: "unknown",
|
CommitSHA: versionInfo.GitCommit,
|
||||||
},
|
},
|
||||||
Findings: []finding.Finding{
|
Findings: []finding.Finding{
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user