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 <github@gone.nl>
  • Loading branch information
thaJeztah committed May 25, 2023
1 parent c21e85d commit 80627e6
Show file tree
Hide file tree
Showing 53 changed files with 27 additions and 23,465 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.9
github.com/mattn/go-sqlite3 v1.14.16
github.com/prometheus/client_golang v1.15.1
github.com/stretchr/testify v1.8.3
github.com/zmap/zcrypto v0.0.0-20220402174210-599ec18ecbac
github.com/zmap/zlint/v3 v3.4.1
golang.org/x/crypto v0.9.0
Expand All @@ -23,24 +22,22 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // 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.3 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/kylelemons/go-gypsy v1.0.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/stretchr/testify v1.8.3 // indirect
github.com/weppos/publicsuffix-go v0.15.1-0.20220329081811-9a40b608a236 // indirect
github.com/ziutek/mymysql v1.5.4 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
)
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,6 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
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.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
10 changes: 6 additions & 4 deletions signer/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
"github.com/cloudflare/cfssl/helpers"
"github.com/cloudflare/cfssl/log"
"github.com/cloudflare/cfssl/signer"
"github.com/stretchr/testify/require"

ct "github.com/google/certificate-transparency-go"
"github.com/zmap/zlint/v3/lint"
)
Expand Down Expand Up @@ -1616,13 +1614,17 @@ func TestLint(t *testing.T) {
} else if err != nil && tc.expectedErr != nil {
actual := err.Error()
expected := tc.expectedErr.Error()
require.Equal(t, expected, actual)
if expected != actual {
t.Fatalf("expected: %v, got: %v", expected, actual)
}
if len(tc.expectedErrResults) > 0 {
le, ok := err.(*LintError)
if !ok {
t.Fatalf("expected LintError type err, got %v", err)
}
require.EqualValues(t, tc.expectedErrResults, le.ErrorResults)
if !reflect.DeepEqual(tc.expectedErrResults, le.ErrorResults) {
t.Fatalf("expected: %v, got: %v", tc.expectedErrResults, le.ErrorResults)
}
}
}
})
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 80627e6

Please sign in to comment.