Skip to content

Commit

Permalink
certdb/sql: remove uses of github.com/stretchr/testify/require
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
thaJeztah committed Nov 22, 2022
1 parent a4a432b commit 5111c3d
Show file tree
Hide file tree
Showing 50 changed files with 21 additions and 22,611 deletions.
28 changes: 20 additions & 8 deletions certdb/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package sql

import (
"math"
"reflect"
"testing"
"time"

"github.com/cloudflare/cfssl/certdb"
"github.com/cloudflare/cfssl/certdb/testdb"

"github.com/jmoiron/sqlx"
"github.com/stretchr/testify/require"
)

const (
Expand Down Expand Up @@ -95,8 +95,13 @@ func testInsertCertificateAndGetCertificate(ta TestAccessor, t *testing.T) {
t.Errorf("want Certificate %+v, got %+v", want, got)
}
gotMeta, err := got.GetMetadata()
require.NoError(t, err)
require.Equal(t, map[string]interface{}{"k": "v"}, gotMeta)
if err != nil {
t.Fatal(err)
}
expected := map[string]interface{}{"k": "v"}
if !reflect.DeepEqual(gotMeta, expected) {
t.Fatalf("expected: %+v, got: %+v", expected, gotMeta)
}

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

Expand Down Expand Up @@ -156,12 +161,19 @@ func testInsertCertificateAndGetUnexpiredCertificate(ta TestAccessor, t *testing
}

unexpiredFiltered, err := ta.Accessor.GetUnexpiredCertificatesByLabel([]string{"foo"})
require.NoError(t, err)
require.Len(t, unexpiredFiltered, 1)
if err != nil {
t.Fatal(err)
}
if l := len(unexpiredFiltered); l != 1 {
t.Error("Should have 1 unexpiredFiltered certificate record:", l)
}
unexpiredFiltered, err = ta.Accessor.GetUnexpiredCertificatesByLabel([]string{"bar"})
require.NoError(t, err)
require.Len(t, unexpiredFiltered, 0)

if err != nil {
t.Fatal(err)
}
if l := len(unexpiredFiltered); l != 0 {
t.Error("Should have 0 unexpiredFiltered certificate record:", l)
}
}
func testInsertCertificateAndGetUnexpiredCertificateNullCommonName(ta TestAccessor, t *testing.T) {
ta.Truncate()
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/lib/pq v1.10.1
github.com/mattn/go-sqlite3 v1.14.15
github.com/prometheus/client_golang v1.13.0
github.com/stretchr/testify v1.7.0
github.com/zmap/zcrypto v0.0.0-20210511125630-18f1e0152cfc
github.com/zmap/zlint/v3 v3.1.0
golang.org/x/crypto v0.3.0
Expand All @@ -24,22 +23,20 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/getsentry/sentry-go v0.11.0 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kylelemons/go-gypsy v1.0.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/weppos/publicsuffix-go v0.15.1-0.20210511084619-b1f36a2d6c0b // indirect
github.com/ziutek/mymysql v1.5.4 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
)
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
15 changes: 0 additions & 15 deletions vendor/github.com/davecgh/go-spew/LICENSE

This file was deleted.

145 changes: 0 additions & 145 deletions vendor/github.com/davecgh/go-spew/spew/bypass.go

This file was deleted.

38 changes: 0 additions & 38 deletions vendor/github.com/davecgh/go-spew/spew/bypasssafe.go

This file was deleted.

Loading

0 comments on commit 5111c3d

Please sign in to comment.