Skip to content

Commit 8d25f25

Browse files
committedJul 29, 2023
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 <github@gone.nl>
1 parent f0549e3 commit 8d25f25

Some content is hidden

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

53 files changed

+27
-23465
lines changed
 

‎certdb/sql/sql_test.go

+20-8
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

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ require (
1414
github.com/lib/pq v1.10.9
1515
github.com/mattn/go-sqlite3 v1.14.17
1616
github.com/prometheus/client_golang v1.16.0
17-
github.com/stretchr/testify v1.8.4
1817
github.com/zmap/zcrypto v0.0.0-20230310154051-c8b263fd8300
1918
github.com/zmap/zlint/v3 v3.5.0
2019
golang.org/x/crypto v0.10.0
@@ -23,24 +22,22 @@ require (
2322
require (
2423
github.com/beorn7/perks v1.0.1 // indirect
2524
github.com/cespare/xxhash/v2 v2.2.0 // indirect
26-
github.com/davecgh/go-spew v1.1.1 // indirect
2725
github.com/getsentry/sentry-go v0.11.0 // indirect
2826
github.com/go-logr/logr v1.2.3 // indirect
2927
github.com/golang/protobuf v1.5.3 // indirect
3028
github.com/kylelemons/go-gypsy v1.0.0 // indirect
3129
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
3230
github.com/pelletier/go-toml v1.9.3 // indirect
33-
github.com/pmezard/go-difflib v1.0.0 // indirect
3431
github.com/prometheus/client_model v0.4.0 // indirect
3532
github.com/prometheus/common v0.42.0 // indirect
3633
github.com/prometheus/procfs v0.10.1 // indirect
3734
github.com/rogpeppe/go-internal v1.10.0 // indirect
35+
github.com/stretchr/testify v1.8.4 // indirect
3836
github.com/weppos/publicsuffix-go v0.30.0 // indirect
3937
github.com/ziutek/mymysql v1.5.4 // indirect
4038
golang.org/x/net v0.10.0 // indirect
4139
golang.org/x/sys v0.9.0 // indirect
4240
golang.org/x/text v0.10.0 // indirect
4341
google.golang.org/protobuf v1.30.0 // indirect
44-
gopkg.in/yaml.v3 v3.0.1 // indirect
4542
k8s.io/klog/v2 v2.100.1 // indirect
4643
)

0 commit comments

Comments
 (0)
Please sign in to comment.