Skip to content

Commit

Permalink
br: migrate test-infra to testify for redact (#29747)
Browse files Browse the repository at this point in the history
  • Loading branch information
tisonkun authored Nov 23, 2021
1 parent 8858592 commit cc8617e
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions br/pkg/redact/redact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,24 @@
package redact_test

import (
"encoding/hex"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/br/pkg/redact"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
)

type testRedactSuite struct{}
func TestRedact(t *testing.T) {
defer goleak.VerifyNone(t)

func (s *testRedactSuite) SetUpSuite(c *C) {}
func (s *testRedactSuite) TearDownSuite(c *C) {}

var _ = Suite(&testRedactSuite{})

func TestT(t *testing.T) {}

func (s *testRedactSuite) TestRedact(c *C) {
redacted, secret := "?", "secret"

redact.InitRedact(false)
c.Assert(redact.String(secret), Equals, secret)
c.Assert(redact.Key([]byte(secret)), Equals, secret)
require.Equal(t, redact.String(secret), secret)
require.Equal(t, redact.Key([]byte(secret)), hex.EncodeToString([]byte(secret)))

redact.InitRedact(true)
c.Assert(redact.String(secret), Equals, redacted)
c.Assert(redact.Key([]byte(secret)), Equals, redacted)
require.Equal(t, redact.String(secret), redacted)
require.Equal(t, redact.Key([]byte(secret)), redacted)
}

0 comments on commit cc8617e

Please sign in to comment.