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

*: migrate test-infra to testify (#344) #347

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 120s \
--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
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/gorilla/websocket v1.4.1 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.14.3 // indirect
github.com/pingcap/br v5.0.4-0.20210723091214-cd2f2da8fa9b+incompatible
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712
github.com/pingcap/errors v0.11.5-0.20201126102027-b0a155152ca3
github.com/pingcap/failpoint v0.0.0-20210316064728-7acb0f0a3dfd
github.com/pingcap/log v0.0.0-20210317133921-96f4fcab92a4
Expand All @@ -26,11 +25,13 @@ require (
github.com/soheilhy/cmux v0.1.4
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/syndtr/goleveldb v1.0.1-0.20190625010220-02440ea7a285 // indirect
github.com/tikv/pd v1.1.0-beta.0.20210323123936-c8fa72502f16
github.com/xitongsys/parquet-go v1.6.0 // indirect
go.etcd.io/bbolt v1.3.5 // indirect
go.etcd.io/etcd v0.5.0-alpha.5.0.20200824191128-ae9734ed278b
go.uber.org/goleak v0.10.0
go.uber.org/zap v1.17.0
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
Expand Down
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