Skip to content

Commit a7b6cee

Browse files
committed
certdb/sql: remove uses of github.com/stretchr/testify/require
This was the only location where this assertion library was used; all other code in this repository used Go's stdlib for assertions. The remaining uses in this package could be replaced without too much trouble, which allowed for the dependency (including its indirect dependencies) to be removed altogether. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 06c7e4c commit a7b6cee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+21
-22611
lines changed

certdb/sql/sql_test.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package sql
22

33
import (
44
"math"
5+
"reflect"
56
"testing"
67
"time"
78

89
"github.com/cloudflare/cfssl/certdb"
910
"github.com/cloudflare/cfssl/certdb/testdb"
1011

1112
"github.com/jmoiron/sqlx"
12-
"github.com/stretchr/testify/require"
1313
)
1414

1515
const (
@@ -95,8 +95,13 @@ func testInsertCertificateAndGetCertificate(ta TestAccessor, t *testing.T) {
9595
t.Errorf("want Certificate %+v, got %+v", want, got)
9696
}
9797
gotMeta, err := got.GetMetadata()
98-
require.NoError(t, err)
99-
require.Equal(t, map[string]interface{}{"k": "v"}, gotMeta)
98+
if err != nil {
99+
t.Fatal(err)
100+
}
101+
expected := map[string]interface{}{"k": "v"}
102+
if !reflect.DeepEqual(gotMeta, expected) {
103+
t.Fatalf("expected: %+v, got: %+v", expected, gotMeta)
104+
}
100105

101106
unexpired, err := ta.Accessor.GetUnexpiredCertificates()
102107

@@ -156,12 +161,19 @@ func testInsertCertificateAndGetUnexpiredCertificate(ta TestAccessor, t *testing
156161
}
157162

158163
unexpiredFiltered, err := ta.Accessor.GetUnexpiredCertificatesByLabel([]string{"foo"})
159-
require.NoError(t, err)
160-
require.Len(t, unexpiredFiltered, 1)
164+
if err != nil {
165+
t.Fatal(err)
166+
}
167+
if l := len(unexpiredFiltered); l != 1 {
168+
t.Error("Should have 1 unexpiredFiltered certificate record:", l)
169+
}
161170
unexpiredFiltered, err = ta.Accessor.GetUnexpiredCertificatesByLabel([]string{"bar"})
162-
require.NoError(t, err)
163-
require.Len(t, unexpiredFiltered, 0)
164-
171+
if err != nil {
172+
t.Fatal(err)
173+
}
174+
if l := len(unexpiredFiltered); l != 0 {
175+
t.Error("Should have 0 unexpiredFiltered certificate record:", l)
176+
}
165177
}
166178
func testInsertCertificateAndGetUnexpiredCertificateNullCommonName(ta TestAccessor, t *testing.T) {
167179
ta.Truncate()

go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ require (
1515
github.com/lib/pq v1.10.1
1616
github.com/mattn/go-sqlite3 v1.14.15
1717
github.com/prometheus/client_golang v1.13.0
18-
github.com/stretchr/testify v1.7.0
1918
github.com/zmap/zcrypto v0.0.0-20210511125630-18f1e0152cfc
2019
github.com/zmap/zlint/v3 v3.1.0
2120
golang.org/x/crypto v0.3.0
@@ -25,22 +24,20 @@ require (
2524
require (
2625
github.com/beorn7/perks v1.0.1 // indirect
2726
github.com/cespare/xxhash/v2 v2.1.2 // indirect
28-
github.com/davecgh/go-spew v1.1.1 // indirect
2927
github.com/getsentry/sentry-go v0.11.0 // indirect
3028
github.com/go-logr/logr v1.2.0 // indirect
3129
github.com/golang/protobuf v1.5.2 // indirect
3230
github.com/kr/text v0.2.0 // indirect
3331
github.com/kylelemons/go-gypsy v1.0.0 // indirect
3432
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
35-
github.com/pmezard/go-difflib v1.0.0 // indirect
3633
github.com/prometheus/client_model v0.2.0 // indirect
3734
github.com/prometheus/common v0.37.0 // indirect
3835
github.com/prometheus/procfs v0.8.0 // indirect
36+
github.com/stretchr/testify v1.7.0 // indirect
3937
github.com/weppos/publicsuffix-go v0.15.1-0.20210511084619-b1f36a2d6c0b // indirect
4038
github.com/ziutek/mymysql v1.5.4 // indirect
4139
golang.org/x/sys v0.2.0 // indirect
4240
golang.org/x/text v0.4.0 // indirect
4341
google.golang.org/protobuf v1.28.1 // indirect
44-
gopkg.in/yaml.v3 v3.0.1 // indirect
4542
k8s.io/klog/v2 v2.80.1 // indirect
4643
)

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
676676
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
677677
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
678678
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
679-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
680679
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
681680
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
682681
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

vendor/github.com/davecgh/go-spew/LICENSE

Lines changed: 0 additions & 15 deletions
This file was deleted.

vendor/github.com/davecgh/go-spew/spew/bypass.go

Lines changed: 0 additions & 145 deletions
This file was deleted.

vendor/github.com/davecgh/go-spew/spew/bypasssafe.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)