Skip to content

Commit 76b7da7

Browse files
committed
tests: add tests
1 parent 8df1ff6 commit 76b7da7

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

pkg/config/config_test.go

+55
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,57 @@ 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 equals to runtime version",
159+
version: getRuntimeGoVersion(),
160+
require: require.NoError,
161+
},
162+
{
163+
desc: "version lower than runtime version (patch)",
164+
version: "1.19.1",
165+
require: require.NoError,
166+
},
167+
{
168+
desc: "version lower than runtime version (family)",
169+
version: "1.19",
170+
require: require.NoError,
171+
},
172+
{
173+
desc: "version lower than runtime version (RC)",
174+
version: "1.19.0-rc1",
175+
require: require.NoError,
176+
},
177+
}
178+
179+
for _, test := range testCases {
180+
test := test
181+
t.Run(test.desc, func(t *testing.T) {
182+
t.Parallel()
183+
184+
err := checkGoVersion(test.version)
185+
test.require(t, err)
186+
})
187+
}
188+
}

0 commit comments

Comments
 (0)