Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
*: migrate test-infra to testify (#344) (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot committed Oct 13, 2021
1 parent 054e170 commit 8f6607b
Show file tree
Hide file tree
Showing 19 changed files with 1,214 additions and 801 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ check:
static: export GO111MODULE=on
static: tools
@ # Not running vet and fmt through metalinter becauase it ends up looking at vendor
tools/bin/gofumports -w -d -format-only -local $(DUMPLING_PKG) $$($(PACKAGE_DIRECTORIES)) 2>&1 | $(CHECKER)
tools/bin/govet --shadow $$($(PACKAGE_DIRECTORIES)) 2>&1 | $(CHECKER)

@# why some lints are disabled?
@# gochecknoglobals - disabled because we do use quite a lot of globals
@# goimports - executed above already, gofumports
@# gofmt - ditto
@# gci - ditto
@# wsl - too pedantic about the formatting
Expand All @@ -76,7 +74,6 @@ static: tools
@# sqlclosecheck - the rows in dumpling is created in one function but closed in other functions
CGO_ENABLED=0 tools/bin/golangci-lint run --enable-all --deadline 180s \
--disable gochecknoglobals \
--disable goimports \
--disable gofmt \
--disable gci \
--disable wsl \
Expand All @@ -97,6 +94,8 @@ static: tools
--disable errorlint \
--disable sqlclosecheck \
--disable scopelint \
--disable gofumpt \
--disable interfacer \
$$($(PACKAGE_DIRECTORIES))
# pingcap/errors APIs are mixed with multiple patterns 'pkg/errors',
# 'juju/errors' and 'pingcap/parser'. To avoid confusion and mistake,
Expand Down
17 changes: 12 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,31 @@ module github.com/pingcap/dumpling
go 1.16

require (
cloud.google.com/go/storage v1.16.1 // indirect
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/coreos/go-semver v0.3.0
github.com/docker/go-units v0.4.0
github.com/go-sql-driver/mysql v1.6.0
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712
github.com/pingcap/badger v1.5.1-0.20210831093107-2f6cb8008145 // indirect
github.com/pingcap/errors v0.11.5-0.20210425183316-da1aaba5fb63
github.com/pingcap/failpoint v0.0.0-20210316064728-7acb0f0a3dfd
github.com/pingcap/log v0.0.0-20210818144256-6455d4a4c6f9
github.com/pingcap/parser v0.0.0-20210823033705-7a7940986a30
github.com/pingcap/tidb v1.1.0-beta.0.20210827045605-d4cadb53ef12
github.com/pingcap/log v0.0.0-20210906054005-afc726e70354
github.com/pingcap/parser v0.0.0-20210831085004-b5390aa83f65
github.com/pingcap/tidb v1.1.0-beta.0.20211013051927-1ff46a93327d
github.com/pingcap/tidb-tools v5.2.0-alpha.0.20210727084616-915b22e4d42c+incompatible
github.com/pingcap/tipb v0.0.0-20210802080519-94b831c6db55 // indirect
github.com/prometheus/client_golang v1.5.1
github.com/prometheus/client_model v0.2.0
github.com/soheilhy/cmux v0.1.4
github.com/spf13/pflag v1.0.5
github.com/tikv/pd v1.1.0-beta.0.20210818082359-acba1da0018d
github.com/stretchr/testify v1.7.0
github.com/tikv/client-go/v2 v2.0.0-alpha.0.20210913094925-a8fa8acd44e7 // indirect
github.com/tikv/pd v1.1.0-beta.0.20210818112400-0c5667766690
github.com/xitongsys/parquet-go v1.6.0 // indirect
go.etcd.io/etcd v0.5.0-alpha.5.0.20200824191128-ae9734ed278b
go.uber.org/goleak v1.1.10
go.uber.org/zap v1.19.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
)

replace google.golang.org/grpc => google.golang.org/grpc v1.29.1
240 changes: 191 additions & 49 deletions go.sum

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
all: bin/gofumports bin/govet bin/revive bin/golangci-lint bin/failpoint-ctl

bin/gofumports:
go build -o $@ mvdan.cc/gofumpt/gofumports
all: bin/govet bin/revive bin/golangci-lint bin/failpoint-ctl

bin/govet:
go build -o $@ github.com/dnephin/govet
Expand Down
1 change: 0 additions & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ require (
github.com/golangci/golangci-lint v1.33.0
github.com/mgechev/revive v1.0.2
github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce
mvdan.cc/gofumpt v0.0.0-20201123090407-3077abae40c0
)
20 changes: 5 additions & 15 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
Expand Down Expand Up @@ -335,8 +334,6 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.6.2 h1:aIihoIOHCiLZHxyoNQ+ABL4NKhFTgKLBdMLyEAh98m0=
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryancurrah/gomodguard v1.1.0 h1:DWbye9KyMgytn8uYpuHkwf0RHqAYO6Ay/D0TbCpPtVU=
github.com/ryancurrah/gomodguard v1.1.0/go.mod h1:4O8tr7hBODaGE6VIhfJDHcwzh5GUccKSJBU0UMXJFVM=
Expand Down Expand Up @@ -476,9 +473,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand All @@ -489,7 +485,6 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -515,14 +510,12 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 h1:bNEHhJCnrwMKNMmOx3yAynp5vs5/gRy+XWFtZFu7NBM=
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down Expand Up @@ -570,9 +563,8 @@ golang.org/x/tools v0.0.0-20201001104356-43ebab892c4c/go.mod h1:z6u4i615ZeAfBE4X
golang.org/x/tools v0.0.0-20201002184944-ecd9fd270d5d/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/tools v0.0.0-20201007032633-0806396f153e/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/tools v0.0.0-20201011145850-ed2f50202694/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/tools v0.0.0-20201013201025-64a9e34f3752 h1:2ntEwh02rqo2jSsrYmp4yKHHjh0CbXP3ZtSUetSB+q8=
golang.org/x/tools v0.0.0-20201013201025-64a9e34f3752/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/tools v0.0.0-20201121010211-780cb80bd7fb h1:z5+u0pkAUPUWd3taoTialQ2JAMo4Wo1Z3L25U4ZV9r0=
golang.org/x/tools v0.0.0-20201121010211-780cb80bd7fb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down Expand Up @@ -611,7 +603,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
Expand All @@ -635,9 +626,8 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
honnef.co/go/tools v0.0.1-2020.1.6 h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc=
honnef.co/go/tools v0.0.1-2020.1.6/go.mod h1:pyyisuGw24ruLjrr1ddx39WE0y9OooInRzEYLhQB2YY=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
mvdan.cc/gofumpt v0.0.0-20200802201014-ab5a8192947d h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=
mvdan.cc/gofumpt v0.0.0-20200802201014-ab5a8192947d/go.mod h1:bzrjFmaD6+xqohD3KYP0H2FEuxknnBmyyOxdhLdaIws=
mvdan.cc/gofumpt v0.0.0-20201123090407-3077abae40c0 h1:kQ90sSvDP83HYKOsmrpDtcKkbWPjWYL2LmSCz1oE6vE=
mvdan.cc/gofumpt v0.0.0-20201123090407-3077abae40c0/go.mod h1:E4LOcu9JQEtnYXtB1Y51drqh2Qr2Ngk9J3YrRCwcbd0=
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed h1:WX1yoOaKQfddO/mLzdV4wptyWgoH/6hwLs7QHTixo0I=
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphDJbHOQO1DFFFTeBo=
Expand Down
4 changes: 1 addition & 3 deletions tools/go_mod_guard.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ import (

// failpoint enables manual 'failure' of some execution points.
_ "github.com/pingcap/failpoint"

// A stricter gofmt
_ "mvdan.cc/gofumpt/gofumports"
_ "github.com/pingcap/failpoint/code"
)
37 changes: 19 additions & 18 deletions v4/export/block_allow_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ package export

import (
"strings"
"testing"

tcontext "github.com/pingcap/dumpling/v4/context"

. "github.com/pingcap/check"
"github.com/pingcap/tidb-tools/pkg/filter"
tf "github.com/pingcap/tidb-tools/pkg/table-filter"
"github.com/stretchr/testify/require"
)

var _ = Suite(&testBWListSuite{})

type testBWListSuite struct{}
func TestFilterTables(t *testing.T) {
t.Parallel()

func (s *testBWListSuite) TestFilterTables(c *C) {
tctx := tcontext.Background().WithLogger(appLogger)
dbTables := DatabaseTables{}
expectedDBTables := DatabaseTables{}
Expand All @@ -28,26 +26,29 @@ func (s *testBWListSuite) TestFilterTables(c *C) {
dbTables.AppendTables("yyy", []string{"xxx"}, []uint64{0})

tableFilter, err := tf.Parse([]string{"*.*"})
c.Assert(err, IsNil)
require.NoError(t, err)

conf := &Config{
ServerInfo: ServerInfo{
ServerType: ServerTypeTiDB,
},
Tables: dbTables,
TableFilter: tableFilter,
}

databases := []string{filter.InformationSchemaName, filter.PerformanceSchemaName, "xxx", "yyy"}
c.Assert(filterDatabases(tctx, conf, databases), DeepEquals, databases)
require.Equal(t, databases, filterDatabases(tctx, conf, databases))

conf.TableFilter = tf.NewSchemasFilter("xxx")
c.Assert(filterDatabases(tctx, conf, databases), DeepEquals, []string{"xxx"})
require.Equal(t, []string{"xxx"}, filterDatabases(tctx, conf, databases))

filterTables(tcontext.Background(), conf)
c.Assert(conf.Tables, HasLen, 1)
c.Assert(conf.Tables, DeepEquals, expectedDBTables)
require.Len(t, conf.Tables, 1)
require.Equal(t, expectedDBTables, conf.Tables)
}

func (s *testBWListSuite) TestFilterDatabaseWithNoTable(c *C) {
func TestFilterDatabaseWithNoTable(t *testing.T) {
t.Parallel()

dbTables := DatabaseTables{}
expectedDBTables := DatabaseTables{}

Expand All @@ -61,21 +62,21 @@ func (s *testBWListSuite) TestFilterDatabaseWithNoTable(c *C) {
DumpEmptyDatabase: true,
}
filterTables(tcontext.Background(), conf)
c.Assert(conf.Tables, HasLen, 0)
require.Len(t, conf.Tables, 0)

dbTables["xxx"] = []*TableInfo{}
expectedDBTables["xxx"] = []*TableInfo{}
conf.Tables = dbTables
conf.TableFilter = tf.NewSchemasFilter("xxx")
filterTables(tcontext.Background(), conf)
c.Assert(conf.Tables, HasLen, 1)
c.Assert(conf.Tables, DeepEquals, expectedDBTables)
require.Len(t, conf.Tables, 1)
require.Equal(t, expectedDBTables, conf.Tables)

dbTables["xxx"] = []*TableInfo{}
expectedDBTables = DatabaseTables{}
conf.Tables = dbTables
conf.DumpEmptyDatabase = false
filterTables(tcontext.Background(), conf)
c.Assert(conf.Tables, HasLen, 0)
c.Assert(conf.Tables, DeepEquals, expectedDBTables)
require.Len(t, conf.Tables, 0)
require.Equal(t, expectedDBTables, conf.Tables)
}
24 changes: 11 additions & 13 deletions v4/export/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
package export

import (
tcontext "github.com/pingcap/dumpling/v4/context"
"testing"

. "github.com/pingcap/check"
tcontext "github.com/pingcap/dumpling/v4/context"
"github.com/stretchr/testify/require"
)

var _ = Suite(&testConfigSuite{})

type testConfigSuite struct{}

func (s *testConfigSuite) TestCreateExternalStorage(c *C) {
mockConfig := defaultConfigForTest(c)
func TestCreateExternalStorage(t *testing.T) {
t.Parallel()
mockConfig := defaultConfigForTest(t)
loc, err := mockConfig.createExternalStorage(tcontext.Background())
c.Assert(err, IsNil)
c.Assert(loc.URI(), Matches, "file:.*")
require.NoError(t, err)
require.Regexp(t, "file:.*", loc.URI())
}

func (s *testConfigSuite) TestMatchMysqlBugversion(c *C) {
func TestMatchMysqlBugVersion(t *testing.T) {
t.Parallel()
cases := []struct {
serverInfo ServerInfo
expected bool
Expand All @@ -31,7 +30,6 @@ func (s *testConfigSuite) TestMatchMysqlBugversion(c *C) {
{ParseServerInfo(tcontext.Background(), "8.0.23"), false},
}
for _, x := range cases {
cmt := Commentf("server info %s", x.serverInfo)
c.Assert(x.expected, Equals, matchMysqlBugversion(x.serverInfo), cmt)
require.Equalf(t, x.expected, matchMysqlBugversion(x.serverInfo), "server info: %s", x.serverInfo)
}
}
Loading

0 comments on commit 8f6607b

Please sign in to comment.