From 0cd802a13b78339fbf17e1b453cd7a41091e2c84 Mon Sep 17 00:00:00 2001 From: Karuppiah Natarajan Date: Sun, 12 Sep 2021 21:53:17 +0530 Subject: [PATCH] util/encrypt: migrate TestAESEncryptWithOFB from test-infra to testify (#27816) Signed-off-by: Karuppiah Natarajan --- util/encrypt/aes_test.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/util/encrypt/aes_test.go b/util/encrypt/aes_test.go index 9be296863f331..3b0bf822cd45f 100644 --- a/util/encrypt/aes_test.go +++ b/util/encrypt/aes_test.go @@ -298,8 +298,7 @@ func TestAESEncryptWithCBC(t *testing.T) { } } -func (s *testEncryptSuite) TestAESEncryptWithOFB(c *C) { - defer testleak.AfterTest(c)() +func TestAESEncryptWithOFB(t *testing.T) { tests := []struct { str string key string @@ -317,19 +316,19 @@ func (s *testEncryptSuite) TestAESEncryptWithOFB(c *C) { {"pingcap", "123456789012345", "1234567890123456", "", true}, } - for _, t := range tests { - str := []byte(t.str) - key := []byte(t.key) - iv := []byte(t.iv) + for _, tt := range tests { + str := []byte(tt.str) + key := []byte(tt.key) + iv := []byte(tt.iv) crypted, err := AESEncryptWithOFB(str, key, iv) - if t.isError { - c.Assert(err, NotNil, Commentf("%v", t)) + 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(crypted) - c.Assert(result, Equals, t.expect, Commentf("%v", t)) + require.Equalf(t, tt.expect, result, "%v", tt) } }