From 462cf4ba6adbce4164c42d4be6978222c3c7ac04 Mon Sep 17 00:00:00 2001 From: Rennbon <343688972@qq.com> Date: Tue, 7 Dec 2021 21:07:57 +0800 Subject: [PATCH] refact: rm testify Author: Rennbon <343688972@qq.com> --- go.mod | 5 +---- go.sum | 10 ---------- rows_test.go | 26 ++++++++++++++++++-------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 2a23532..6f58b70 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,4 @@ module github.com/DATA-DOG/go-sqlmock go 1.15 -require ( - github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46 - github.com/stretchr/testify v1.7.0 // indirect -) +require github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46 diff --git a/go.sum b/go.sum index 8c53630..a21f637 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,2 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46 h1:veS9QfglfvqAw2e+eeNT/SbGySq8ajECXJ9e4fPoLhY= github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/rows_test.go b/rows_test.go index f88a9ef..c8cb614 100644 --- a/rows_test.go +++ b/rows_test.go @@ -5,7 +5,7 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/stretchr/testify/assert" + "reflect" "testing" "time" ) @@ -774,9 +774,14 @@ func TestNewRowsFromStruct(t *testing.T) { if err != nil { t.Fatal(err) } - assert.EqualValues(t, excepted.cols, actual.cols) - assert.EqualValues(t, excepted.rows, actual.rows) - assert.EqualValues(t, excepted.def, actual.def) + same := reflect.DeepEqual(excepted.cols, actual.cols) + if !same { + t.Fatal("custom tag reflect failed") + } + same = reflect.DeepEqual(excepted.rows, actual.rows) + if !same { + t.Fatal("reflect value from tag failed") + } } func TestNewRowsFromStructs(t *testing.T) { @@ -796,11 +801,16 @@ func TestNewRowsFromStructs(t *testing.T) { for _, v := range arr { excepted.AddRow(v.Type, v.Name, v.CreateTime) } - actual, err := NewRowsFromStructs("mock", arr[0],arr[1]) + actual, err := NewRowsFromStructs("mock", arr[0], arr[1]) if err != nil { t.Fatal(err) } - assert.EqualValues(t, excepted.cols, actual.cols) - assert.EqualValues(t, excepted.rows, actual.rows) - assert.EqualValues(t, excepted.def, actual.def) + same := reflect.DeepEqual(excepted.cols, actual.cols) + if !same { + t.Fatal("custom tag reflect failed") + } + same = reflect.DeepEqual(excepted.rows, actual.rows) + if !same { + t.Fatal("reflect value from tag failed") + } }