Skip to content

Commit 5c54f90

Browse files
committed
tests: add tests
1 parent 8df1ff6 commit 5c54f90

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

pkg/config/config_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"testing"
55

66
"github.com/stretchr/testify/assert"
7+
"github.com/stretchr/testify/require"
78
)
89

910
func TestIsGoGreaterThanOrEqual(t *testing.T) {
@@ -131,3 +132,52 @@ func Test_trimGoVersion(t *testing.T) {
131132
})
132133
}
133134
}
135+
136+
func Test_checkGoVersion(t *testing.T) {
137+
testCases := []struct {
138+
desc string
139+
version string
140+
require require.ErrorAssertionFunc
141+
}{
142+
{
143+
desc: "version greater than runtime version (patch)",
144+
version: "1.30.1",
145+
require: require.Error,
146+
},
147+
{
148+
desc: "version greater than runtime version (family)",
149+
version: "1.30",
150+
require: require.Error,
151+
},
152+
{
153+
desc: "version greater than runtime version (RC)",
154+
version: "1.30.0-rc1",
155+
require: require.Error,
156+
},
157+
{
158+
desc: "version lower than runtime version (patch)",
159+
version: "1.19.1",
160+
require: require.NoError,
161+
},
162+
{
163+
desc: "version lower than runtime version (family)",
164+
version: "1.19",
165+
require: require.NoError,
166+
},
167+
{
168+
desc: "version lower than runtime version (RC)",
169+
version: "1.19.0-rc1",
170+
require: require.NoError,
171+
},
172+
}
173+
174+
for _, test := range testCases {
175+
test := test
176+
t.Run(test.desc, func(t *testing.T) {
177+
t.Parallel()
178+
179+
err := checkGoVersion(test.version)
180+
test.require(t, err)
181+
})
182+
}
183+
}

0 commit comments

Comments
 (0)