From 615f97cef51b2b954505dbf173a0dc0712f8b35e Mon Sep 17 00:00:00 2001 From: Karuppiah Natarajan Date: Mon, 13 Sep 2021 20:50:34 +0530 Subject: [PATCH] util/encrypt: migrate TestSQLDecode from test-infra to testify (#27816) Signed-off-by: Karuppiah Natarajan --- util/encrypt/crypt_test.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/util/encrypt/crypt_test.go b/util/encrypt/crypt_test.go index e168d7482c45f..1ffbcaba9ecdd 100644 --- a/util/encrypt/crypt_test.go +++ b/util/encrypt/crypt_test.go @@ -15,12 +15,14 @@ package encrypt import ( + "testing" + . "github.com/pingcap/check" "github.com/pingcap/tidb/util/testleak" + "github.com/stretchr/testify/require" ) -func (s *testEncryptSuite) TestSQLDecode(c *C) { - defer testleak.AfterTest(c)() +func TestSQLDecode(t *testing.T) { tests := []struct { str string passwd string @@ -39,15 +41,15 @@ func (s *testEncryptSuite) TestSQLDecode(c *C) { {"pingcap数据库", "数据库passwd12345667", "36D5F90D3834E30E396BE3226E3B4ED3", false}, } - for _, t := range tests { - crypted, err := SQLDecode(t.str, t.passwd) - if t.isError { - c.Assert(err, NotNil, Commentf("%v", t)) + for _, tt := range tests { + crypted, err := SQLDecode(tt.str, tt.passwd) + if tt.isError { + require.Errorf(t, err, "%v", tt) continue } - c.Assert(err, IsNil, Commentf("%v", t)) + require.NoErrorf(t, err, "%v", tt) result := toHex([]byte(crypted)) - c.Assert(result, Equals, t.expect, Commentf("%v", t)) + require.Equalf(t, tt.expect, result, "%v", tt) } }