Skip to content

Commit

Permalink
util/encrypt: migrate TestSQLEncode from test-infra to testify (pingc…
Browse files Browse the repository at this point in the history
…ap#27816)

Signed-off-by: Karuppiah Natarajan <karuppiah7890@users.noreply.github.com>
  • Loading branch information
karuppiah7890 committed Sep 13, 2021
1 parent 615f97c commit e17f2b0
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions util/encrypt/crypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ package encrypt
import (
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/util/testleak"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -53,8 +51,7 @@ func TestSQLDecode(t *testing.T) {
}
}

func (s *testEncryptSuite) TestSQLEncode(c *C) {
defer testleak.AfterTest(c)()
func TestSQLEncode(t *testing.T) {
tests := []struct {
str string
passwd string
Expand All @@ -73,15 +70,15 @@ func (s *testEncryptSuite) TestSQLEncode(c *C) {
{"pingcap数据库", "数据库passwd12345667", "pingcap数据库", false},
}

for _, t := range tests {
crypted, err := SQLDecode(t.str, t.passwd)
c.Assert(err, IsNil)
uncrypte, err := SQLEncode(crypted, t.passwd)
if t.isError {
c.Assert(err, NotNil, Commentf("%v", t))
for _, tt := range tests {
crypted, err := SQLDecode(tt.str, tt.passwd)
require.NoError(t, err)
uncrypte, err := SQLEncode(crypted, tt.passwd)
if tt.isError {
require.Errorf(t, err, "%v", tt)
continue
}
c.Assert(err, IsNil, Commentf("%v", t))
c.Assert(uncrypte, Equals, t.expect, Commentf("%v", t))
require.NoError(t, err, "%v", tt)
require.Equal(t, tt.expect, uncrypte, "%v", tt)
}
}

0 comments on commit e17f2b0

Please sign in to comment.