Skip to content

Commit

Permalink
up: replace the assert pkg from stretchr/testify to gookit/goutil
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jun 24, 2023
1 parent bd322ae commit b04bd7a
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.log
*.swp
.idea
.idea/
.fleet/
*.patch
### Go template
# Binaries for programs and plugins
Expand Down
2 changes: 1 addition & 1 deletion data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/gookit/goutil/dump"
"github.com/stretchr/testify/assert"
"github.com/gookit/goutil/testutil/assert"
)

func TestData(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion filtering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/url"
"testing"

"github.com/stretchr/testify/assert"
"github.com/gookit/goutil/testutil/assert"
)

func TestFilterOnStruct(t *testing.T) {
Expand Down
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ go 1.18
require (
github.com/gookit/filter v1.1.4
github.com/gookit/goutil v0.6.10
github.com/stretchr/testify v1.8.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gookit/color v1.5.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
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=
Expand Down
27 changes: 26 additions & 1 deletion issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/gookit/goutil/dump"
"github.com/gookit/goutil/jsonutil"
"github.com/gookit/goutil/testutil/assert"
"github.com/gookit/validate"
"github.com/stretchr/testify/assert"
)

func TestIssue_2(t *testing.T) {
Expand Down Expand Up @@ -1259,3 +1259,28 @@ func TestIssues_172(t *testing.T) {

assert.Equal(t, []string{"test.com", "oof.com", "foobar.com"}, f.Domains)
}

// https://github.com/gookit/validate/issues/213
func TestIssues_141(t *testing.T) {
type Person struct {
Name string `json:"name" validate:"required"`
Age int `json:"age" validate:"required"`
}
type Form struct {
Data []Person `validate:"required"`
}

f := &Form{}
v := validate.Struct(&f) // nolint:varnamelen
assert.False(t, v.Validate())
fmt.Println(v.Errors)

f = &Form{
Data: []Person{
{Name: "tome"},
},
}
v = validate.Struct(&f) // nolint:varnamelen
assert.False(t, v.Validate())
fmt.Println(v.Errors)
}
2 changes: 1 addition & 1 deletion locales/ruru/ruru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ruru
import (
"testing"

"github.com/gookit/goutil/testutil/assert"
"github.com/gookit/validate"
"github.com/stretchr/testify/assert"
)

func TestRegister(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion locales/zhcn/zhcn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package zhcn
import (
"testing"

"github.com/gookit/goutil/testutil/assert"
"github.com/gookit/validate"
"github.com/stretchr/testify/assert"
)

func TestRegister(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion locales/zhtw/zhtw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package zhtw
import (
"testing"

"github.com/gookit/goutil/testutil/assert"
"github.com/gookit/validate"
"github.com/stretchr/testify/assert"
)

func TestRegister(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/gookit/goutil/dump"
"github.com/gookit/goutil/jsonutil"
"github.com/stretchr/testify/assert"
"github.com/gookit/goutil/testutil/assert"
)

func TestBuiltinMessages(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion morecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"testing"

"github.com/gookit/goutil/dump"
"github.com/gookit/goutil/testutil/assert"
"github.com/gookit/validate"
"github.com/stretchr/testify/assert"
)

func TestValidation_custom_type(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/gookit/filter"
"github.com/stretchr/testify/assert"
"github.com/gookit/goutil/testutil/assert"
)

func TestRule_basic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/gookit/goutil/dump"
"github.com/stretchr/testify/assert"
"github.com/gookit/goutil/testutil/assert"
)

func TestValueLen(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/gookit/goutil/dump"
"github.com/stretchr/testify/assert"
"github.com/gookit/goutil/testutil/assert"
)

// func TestMain(m *testing.M) {
Expand Down
2 changes: 1 addition & 1 deletion validating_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package validate
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/gookit/goutil/testutil/assert"
)

func TestNew(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"

"github.com/gookit/goutil/dump"
"github.com/stretchr/testify/assert"
"github.com/gookit/goutil/testutil/assert"
)

var mpSample = M{
Expand Down
2 changes: 1 addition & 1 deletion validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/stretchr/testify/assert"
"github.com/gookit/goutil/testutil/assert"
)

func TestIsEmpty(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package validate_test
import (
"testing"

"github.com/gookit/goutil/testutil/assert"
"github.com/gookit/validate"
"github.com/stretchr/testify/assert"
)

func TestVal_basic(t *testing.T) {
Expand Down

0 comments on commit b04bd7a

Please sign in to comment.