Skip to content

Commit 9ada2e3

Browse files
authored
Merge pull request #21 from thaJeztah/stdlib_testing
replace testify with stdlib in tests
2 parents 458d3b7 + 86a86b7 commit 9ada2e3

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

defaults_windows_test.go

+15-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"testing"
2525

2626
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
27-
"github.com/stretchr/testify/assert"
2827
"golang.org/x/sys/windows"
2928
)
3029

@@ -66,7 +65,9 @@ func TestDefaultMatchComparer(t *testing.T) {
6665
match: false,
6766
},
6867
} {
69-
assert.Equal(t, test.match, defaultMatcher.Match(test.platform))
68+
if actual := defaultMatcher.Match(test.platform); actual != test.match {
69+
t.Errorf("expected: %v, actual: %v", test.match, actual)
70+
}
7071
}
7172

7273
}
@@ -138,7 +139,9 @@ func TestMatchComparerMatch_WCOW(t *testing.T) {
138139
match: false,
139140
},
140141
} {
141-
assert.Equal(t, test.match, m.Match(test.platform), "should match: %t, %s to %s", test.match, m.Platform, test.platform)
142+
if actual := m.Match(test.platform); actual != test.match {
143+
t.Errorf("should match: %t, %s to %s", test.match, m.Platform, test.platform)
144+
}
142145
}
143146
}
144147

@@ -262,7 +265,9 @@ func TestMatchComparerMatch_ABICheckWCOW(t *testing.T) {
262265
match: true,
263266
},
264267
} {
265-
assert.Equal(t, test.match, test.hostPlatformMatcher.Match(test.testPlatform), "should match: %t, %s to %s", test.match, test.hostPlatformMatcher.Platform, test.testPlatform)
268+
if actual := test.hostPlatformMatcher.Match(test.testPlatform); actual != test.match {
269+
t.Errorf("should match: %t, %s to %s", test.match, test.hostPlatformMatcher.Platform, test.testPlatform)
270+
}
266271
}
267272
}
268273

@@ -323,7 +328,9 @@ func TestMatchComparerMatch_LCOW(t *testing.T) {
323328
match: true,
324329
},
325330
} {
326-
assert.Equal(t, test.match, m.Match(test.platform), "should match %b, %s to %s", test.match, m.Platform, test.platform)
331+
if actual := m.Match(test.platform); actual != test.match {
332+
t.Errorf("should match: %t, %s to %s", test.match, m.Platform, test.platform)
333+
}
327334
}
328335
}
329336

@@ -390,5 +397,7 @@ func TestMatchComparerLess(t *testing.T) {
390397
sort.SliceStable(platforms, func(i, j int) bool {
391398
return m.Less(platforms[i], platforms[j])
392399
})
393-
assert.Equal(t, expected, platforms)
400+
if !reflect.DeepEqual(platforms, expected) {
401+
t.Errorf("expected: %s\nactual : %s", expected, platforms)
402+
}
394403
}

go.mod

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ go 1.20
55
require (
66
github.com/containerd/log v0.1.0
77
github.com/opencontainers/image-spec v1.1.0
8-
github.com/stretchr/testify v1.8.4
98
golang.org/x/sys v0.26.0
109
)
1110

1211
require (
13-
github.com/davecgh/go-spew v1.1.1 // indirect
1412
github.com/opencontainers/go-digest v1.0.0 // indirect
15-
github.com/pmezard/go-difflib v1.0.0 // indirect
1613
github.com/sirupsen/logrus v1.9.3 // indirect
17-
gopkg.in/yaml.v3 v3.0.1 // indirect
14+
github.com/stretchr/testify v1.8.4 // indirect
1815
)

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
1818
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1919
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
2020
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
21-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2221
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2322
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2423
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
25-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

platforms_windows_test.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
1717
package platforms
1818

1919
import (
20+
"reflect"
2021
"testing"
2122

2223
specs "github.com/opencontainers/image-spec/specs-go/v1"
23-
"github.com/stretchr/testify/require"
2424
)
2525

2626
func TestNormalize(t *testing.T) {
27-
require.Equal(t, DefaultSpec(), Normalize(DefaultSpec()))
27+
s := DefaultSpec()
28+
n := Normalize(DefaultSpec())
29+
if !reflect.DeepEqual(s, n) {
30+
t.Errorf("Normalize returned %+v, expected %+v", n, s)
31+
}
2832
}
2933

3034
func TestFallbackOnOSVersion(t *testing.T) {
@@ -37,5 +41,7 @@ func TestFallbackOnOSVersion(t *testing.T) {
3741
other := specs.Platform{OS: p.OS, Architecture: p.Architecture}
3842

3943
m := NewMatcher(p)
40-
require.True(t, m.Match(other))
44+
if !m.Match(other) {
45+
t.Errorf("Expected %+v to match", other)
46+
}
4147
}

0 commit comments

Comments
 (0)