Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/uv/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/snyk/error-catalog-golang-public/snyk_errors"
)

var minVersion = Version{0, 9, 11}
var minVersion = Version{0, 9, 23}

// cmdExecutor interface for executing commands mockable.
type cmdExecutor interface {
Expand Down
20 changes: 18 additions & 2 deletions internal/uv/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ func buildTestHelper(t *testing.T) string {
}

func TestDefaultCmdExecutor(t *testing.T) {
mockMinVersion(t)
helperBin := buildTestHelper(t)
version := formatVersion(minVersion)
version := formatVersion(testMinVersion)
t.Setenv("TESTHELPER_VERSION", version)

t.Run("returns stdout only", func(t *testing.T) {
Expand Down Expand Up @@ -121,7 +122,20 @@ func TestDefaultCmdExecutor(t *testing.T) {
})
}

// value used to mock out `minVersion`.
var testMinVersion = Version{0, 9, 11}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mocked this out to prevent tests failing each time we bump the version


// sets the package var `minVersion` to the mock value `testMinVersion`.
func mockMinVersion(t *testing.T) {
t.Helper()
original := minVersion
minVersion = testMinVersion
t.Cleanup(func() { minVersion = original })
}

func TestParseAndValidateVersion_ValidVersions(t *testing.T) {
mockMinVersion(t)

tests := []struct {
name string
output string
Expand All @@ -145,6 +159,8 @@ func TestParseAndValidateVersion_ValidVersions(t *testing.T) {
}

func TestParseAndValidateVersion_InvalidVersions(t *testing.T) {
mockMinVersion(t)

tests := []struct {
name string
output string
Expand All @@ -165,7 +181,7 @@ func TestParseAndValidateVersion_InvalidVersions(t *testing.T) {
var catalogErr snyk_errors.Error
assert.True(t, errors.As(err, &catalogErr), "error should be a catalog error")
assert.Contains(t, catalogErr.Detail, "not supported")
assert.Contains(t, catalogErr.Detail, "0.9.11")
assert.Contains(t, catalogErr.Detail, formatVersion(testMinVersion))
})
}
}
Expand Down