Skip to content

Commit 17c859f

Browse files
committed
Add tests for osversion matching with no version
Signed-off-by: Derek McGowan <[email protected]>
1 parent c1438e9 commit 17c859f

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

compare_test.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ func TestOnly(t *testing.T) {
7878
{
7979
platform: "windows/amd64",
8080
matches: map[bool][]string{
81-
true: {"windows/amd64"},
81+
true: {
82+
"windows/amd64",
83+
"windows(10.0.17763)/amd64",
84+
},
8285
false: {
8386
"linux/amd64",
8487
"linux/arm/v7",
@@ -265,7 +268,25 @@ func TestOnlyStrict(t *testing.T) {
265268
{
266269
platform: "windows/amd64",
267270
matches: map[bool][]string{
268-
true: {"windows/amd64"},
271+
true: {
272+
"windows/amd64",
273+
"windows(10.0.17763)/amd64",
274+
},
275+
false: {
276+
"linux/amd64",
277+
"linux/arm/v7",
278+
"linux/arm64",
279+
"windows/arm",
280+
},
281+
},
282+
},
283+
{
284+
platform: "windows(10.0.17763)/amd64",
285+
matches: map[bool][]string{
286+
true: {
287+
"windows/amd64",
288+
"windows(10.0.17763)/amd64",
289+
},
269290
false: {
270291
"linux/amd64",
271292
"linux/arm/v7",

defaults_windows_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ func TestMatchComparerMatch_WCOW(t *testing.T) {
145145
// TestMatchComparerMatch_ABICheckWCOW checks windows platform matcher
146146
// behavior for stable ABI and non-stable ABI compliant versions
147147
func TestMatchComparerMatch_ABICheckWCOW(t *testing.T) {
148+
platformNoVersion := imagespec.Platform{
149+
Architecture: "amd64",
150+
OS: "windows",
151+
}
148152
platformWS2019 := imagespec.Platform{
149153
Architecture: "amd64",
150154
OS: "windows",
@@ -160,6 +164,7 @@ func TestMatchComparerMatch_ABICheckWCOW(t *testing.T) {
160164
OS: "windows",
161165
OSVersion: "10.0.22621",
162166
}
167+
matcherNoVersion := NewMatcher(platformNoVersion).(windowsmatcher)
163168
matcherWS2019 := windowsmatcher{
164169
Platform: platformWS2019,
165170
osVersionPrefix: platformWS2019.OSVersion,
@@ -241,6 +246,21 @@ func TestMatchComparerMatch_ABICheckWCOW(t *testing.T) {
241246
},
242247
match: true,
243248
},
249+
{
250+
hostPlatformMatcher: matcherNoVersion,
251+
testPlatform: platformWS2019,
252+
match: true,
253+
},
254+
{
255+
hostPlatformMatcher: matcherNoVersion,
256+
testPlatform: platformNoVersion,
257+
match: true,
258+
},
259+
{
260+
hostPlatformMatcher: matcherNoVersion,
261+
testPlatform: platformWindows11,
262+
match: true,
263+
},
244264
} {
245265
assert.Equal(t, test.match, test.hostPlatformMatcher.Match(test.testPlatform), "should match: %t, %s to %s", test.match, test.hostPlatformMatcher.Platform, test.testPlatform)
246266
}

0 commit comments

Comments
 (0)