Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

br: migrate test-infra to testify for br/pkg/task/backup_test.go #30280

Closed
wants to merge 7 commits into from
Closed
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
43 changes: 18 additions & 25 deletions br/pkg/task/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,49 @@ import (
"testing"
"time"

. "github.com/pingcap/check"
backuppb "github.com/pingcap/kvproto/pkg/brpb"
"github.com/stretchr/testify/require"
)

var _ = Suite(&testBackupSuite{})

func TestT(t *testing.T) {
TestingT(t)
}

type testBackupSuite struct{}

func (s *testBackupSuite) TestParseTSString(c *C) {
func TestParseTSString(t *testing.T) {
var (
ts uint64
err error
)

ts, err = parseTSString("")
c.Assert(err, IsNil)
c.Assert(int(ts), Equals, 0)
require.NoError(t, err)
require.Equal(t, 0, int(ts))

ts, err = parseTSString("400036290571534337")
c.Assert(err, IsNil)
c.Assert(int(ts), Equals, 400036290571534337)
require.NoError(t, err)
require.Equal(t, 400036290571534337, int(ts))

_, offset := time.Now().Local().Zone()
ts, err = parseTSString("2018-05-11 01:42:23")
c.Assert(err, IsNil)
c.Assert(int(ts), Equals, 400032515489792000-(offset*1000)<<18)
require.NoError(t, err)
require.Equal(t, 400032515489792000-(offset*1000)<<18, int(ts))
}

func (s *testBackupSuite) TestParseCompressionType(c *C) {
func TestParseCompressionType(t *testing.T) {
var (
ct backuppb.CompressionType
err error
)
ct, err = parseCompressionType("lz4")
c.Assert(err, IsNil)
c.Assert(int(ct), Equals, 1)
require.NoError(t, err)
require.Equal(t, 1, int(ct))

ct, err = parseCompressionType("snappy")
c.Assert(err, IsNil)
c.Assert(int(ct), Equals, 2)
require.NoError(t, err)
require.Equal(t, 2, int(ct))

ct, err = parseCompressionType("zstd")
c.Assert(err, IsNil)
c.Assert(int(ct), Equals, 3)
require.NoError(t, err)
require.Equal(t, 3, int(ct))

ct, err = parseCompressionType("Other Compression (strings)")
c.Assert(err, ErrorMatches, "invalid compression.*")
c.Assert(int(ct), Equals, 0)
require.EqualError(t, err, "invalid compression type 'Other Compression (strings)': [BR:Common:ErrInvalidArgument]invalid argument")
//c.Assert(err, ErrorMatches, "invalid compression.*")
require.Equal(t, 0, int(ct))
}