acct.cpp 1.4 KB
Newer Older
S
Shengliang Guan 已提交
1
/**
S
Shengliang Guan 已提交
2
 * @file acct.cpp
S
Shengliang Guan 已提交
3
 * @author slguan (slguan@taosdata.com)
S
Shengliang Guan 已提交
4 5
 * @brief MNODE module acct tests
 * @version 1.0
S
Shengliang Guan 已提交
6
 * @date 2022-01-04
S
Shengliang Guan 已提交
7
 *
S
Shengliang Guan 已提交
8
 * @copyright Copyright (c) 2022
S
Shengliang Guan 已提交
9 10 11
 *
 */

S
Shengliang Guan 已提交
12
#include "sut.h"
S
Shengliang Guan 已提交
13

S
Shengliang Guan 已提交
14
class MndTestAcct : public ::testing::Test {
S
Shengliang Guan 已提交
15
 protected:
16
  static void SetUpTestSuite() { test.Init(TD_TMP_DIR_PATH "acctTest", 9012); }
S
Shengliang Guan 已提交
17
  static void TearDownTestSuite() { test.Cleanup(); }
S
Shengliang Guan 已提交
18

S
Shengliang Guan 已提交
19
  static Testbase test;
S
Shengliang Guan 已提交
20

S
Shengliang Guan 已提交
21 22 23 24
 public:
  void SetUp() override {}
  void TearDown() override {}
};
S
Shengliang Guan 已提交
25

S
Shengliang Guan 已提交
26
Testbase MndTestAcct::test;
S
Shengliang Guan 已提交
27

S
Shengliang Guan 已提交
28
TEST_F(MndTestAcct, 01_Create_Acct) {
S
Shengliang Guan 已提交
29
  int32_t contLen = sizeof(SCreateAcctReq);
S
Shengliang Guan 已提交
30

S
Shengliang Guan 已提交
31
  SCreateAcctReq* pReq = (SCreateAcctReq*)rpcMallocCont(contLen);
S
Shengliang Guan 已提交
32

S
Shengliang Guan 已提交
33 34
  SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_ACCT, pReq, contLen);
  ASSERT_NE(pRsp, nullptr);
35
  ASSERT_EQ(pRsp->code, TSDB_CODE_MSG_NOT_PROCESSED);
S
Shengliang Guan 已提交
36 37
}

S
Shengliang Guan 已提交
38
TEST_F(MndTestAcct, 02_Alter_Acct) {
S
Shengliang Guan 已提交
39
  int32_t contLen = sizeof(SCreateAcctReq);
S
Shengliang Guan 已提交
40

S
Shengliang Guan 已提交
41
  SAlterAcctReq* pReq = (SAlterAcctReq*)rpcMallocCont(contLen);
S
Shengliang Guan 已提交
42

S
Shengliang Guan 已提交
43 44
  SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_ACCT, pReq, contLen);
  ASSERT_NE(pRsp, nullptr);
45
  ASSERT_EQ(pRsp->code, TSDB_CODE_MSG_NOT_PROCESSED);
S
Shengliang Guan 已提交
46 47
}

S
Shengliang Guan 已提交
48
TEST_F(MndTestAcct, 03_Drop_Acct) {
S
Shengliang Guan 已提交
49
  int32_t contLen = sizeof(SDropAcctReq);
S
Shengliang Guan 已提交
50

S
Shengliang Guan 已提交
51
  SDropAcctReq* pReq = (SDropAcctReq*)rpcMallocCont(contLen);
S
Shengliang Guan 已提交
52

S
Shengliang Guan 已提交
53 54
  SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_ACCT, pReq, contLen);
  ASSERT_NE(pRsp, nullptr);
55
  ASSERT_EQ(pRsp->code, TSDB_CODE_MSG_NOT_PROCESSED);
S
Shengliang Guan 已提交
56
}