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 479286c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 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,56 @@ 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 equals to runtime version",
version: getRuntimeGoVersion(),
require: require.NoError,
},
{
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 {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

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

0 comments on commit 479286c

Please # to comment.