Skip to content

Commit

Permalink
tests: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Aug 21, 2024
1 parent 8df1ff6 commit 5c54f90
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestIsGoGreaterThanOrEqual(t *testing.T) {
Expand Down Expand Up @@ -131,3 +132,52 @@ func Test_trimGoVersion(t *testing.T) {
})
}
}

func Test_checkGoVersion(t *testing.T) {
testCases := []struct {
desc string
version string
require require.ErrorAssertionFunc
}{
{
desc: "version greater than runtime version (patch)",
version: "1.30.1",
require: require.Error,
},
{
desc: "version greater than runtime version (family)",
version: "1.30",
require: require.Error,
},
{
desc: "version greater than runtime version (RC)",
version: "1.30.0-rc1",
require: require.Error,
},
{
desc: "version lower than runtime version (patch)",
version: "1.19.1",
require: require.NoError,
},
{
desc: "version lower than runtime version (family)",
version: "1.19",
require: require.NoError,
},
{
desc: "version lower than runtime version (RC)",
version: "1.19.0-rc1",
require: require.NoError,
},
}

for _, test := range testCases {
test := test

Check failure on line 175 in pkg/config/config_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

The copy of the 'for' variable "test" can be deleted (Go 1.22+) (copyloopvar)
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

err := checkGoVersion(test.version)
test.require(t, err)
})
}
}

0 comments on commit 5c54f90

Please sign in to comment.