Skip to content

Commit 5ae90c6

Browse files
committed
Add failing test cases for current
1 parent f01414f commit 5ae90c6

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

platforms/compare_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@
1717
package platforms
1818

1919
import (
20+
"fmt"
21+
"golang.org/x/sys/windows"
2022
"testing"
2123
)
2224

2325
func TestOnly(t *testing.T) {
26+
// will not work on linux. Demonstrates that build strings don't work with Only() and other variants
27+
major, minor, build := windows.RtlGetNtVersionNumbers()
28+
buildStr := fmt.Sprintf("%d.%d.%d", major, minor, build)
29+
2430
for _, tc := range []struct {
2531
platform string
2632
matches map[bool][]string
@@ -75,6 +81,18 @@ func TestOnly(t *testing.T) {
7581
},
7682
},
7783
},
84+
{
85+
platform: fmt.Sprintf("windows/amd64//%s", buildStr+".1"),
86+
matches: map[bool][]string{
87+
true: { fmt.Sprintf("windows/amd64//%s", buildStr)},
88+
false: {
89+
"linux/amd64",
90+
"linux/arm/v7",
91+
"linux/arm64",
92+
"windows/arm",
93+
},
94+
},
95+
},
7896
{
7997
platform: "windows/amd64",
8098
matches: map[bool][]string{

platforms/defaults_windows_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,30 @@ func TestDefault(t *testing.T) {
4747
}
4848
}
4949

50+
func TestDefaultMatchComparer(t *testing.T) {
51+
defaultMatcher := Default()
52+
53+
for _, test := range []struct {
54+
platform imagespec.Platform
55+
match bool
56+
}{
57+
{
58+
platform: DefaultSpec(),
59+
match: true,
60+
},
61+
{
62+
platform: imagespec.Platform{
63+
OS: "linux",
64+
Architecture: runtime.GOARCH,
65+
},
66+
match: true,
67+
},
68+
} {
69+
assert.Equal(t, test.match, defaultMatcher.Match(test.platform))
70+
}
71+
72+
}
73+
5074
func TestMatchComparerMatch(t *testing.T) {
5175
major, minor, build := windows.RtlGetNtVersionNumbers()
5276
buildStr := fmt.Sprintf("%d.%d.%d", major, minor, build)

0 commit comments

Comments
 (0)