acct.cpp 1.7 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
 * @brief DNODE module acct-msg tests
S
Shengliang Guan 已提交
5 6
 * @version 0.1
 * @date 2021-12-15
S
Shengliang Guan 已提交
7
 *
S
Shengliang Guan 已提交
8
 * @copyright Copyright (c) 2021
S
Shengliang Guan 已提交
9 10 11
 *
 */

S
Shengliang Guan 已提交
12
#include "base.h"
S
Shengliang Guan 已提交
13 14 15

class DndTestAcct : public ::testing::Test {
 protected:
S
Shengliang Guan 已提交
16 17
  static void SetUpTestSuite() { test.Init("/tmp/dnode_test_acct", 9012); }
  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 27
TEST_F(DndTestAcct, 01_CreateAcct) {
  int32_t contLen = sizeof(SCreateAcctMsg);
S
Shengliang Guan 已提交
28

S
Shengliang Guan 已提交
29
  SCreateAcctMsg* pReq = (SCreateAcctMsg*)rpcMallocCont(contLen);
S
Shengliang Guan 已提交
30

S
Shengliang Guan 已提交
31
  SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_ACCT, pReq, contLen);
S
Shengliang Guan 已提交
32 33 34 35
  ASSERT_NE(pMsg, nullptr);
  ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
}

S
Shengliang Guan 已提交
36
TEST_F(DndTestAcct, 02_AlterAcct) {
S
Shengliang Guan 已提交
37
  int32_t contLen = sizeof(SCreateAcctMsg);
S
Shengliang Guan 已提交
38

S
Shengliang Guan 已提交
39
  SAlterAcctMsg* pReq = (SAlterAcctMsg*)rpcMallocCont(contLen);
S
Shengliang Guan 已提交
40

S
Shengliang Guan 已提交
41
  SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_ALTER_ACCT, pReq, contLen);
S
Shengliang Guan 已提交
42 43 44 45
  ASSERT_NE(pMsg, nullptr);
  ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
}

S
Shengliang Guan 已提交
46
TEST_F(DndTestAcct, 03_DropAcct) {
S
Shengliang Guan 已提交
47
  int32_t contLen = sizeof(SDropAcctMsg);
S
Shengliang Guan 已提交
48

S
Shengliang Guan 已提交
49
  SDropAcctMsg* pReq = (SDropAcctMsg*)rpcMallocCont(contLen);
S
Shengliang Guan 已提交
50

S
Shengliang Guan 已提交
51
  SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_DROP_ACCT, pReq, contLen);
S
Shengliang Guan 已提交
52 53 54 55
  ASSERT_NE(pMsg, nullptr);
  ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
}

S
Shengliang Guan 已提交
56
TEST_F(DndTestAcct, 04_ShowAcct) {
S
Shengliang Guan 已提交
57
  int32_t contLen = sizeof(SShowMsg);
S
Shengliang Guan 已提交
58

S
Shengliang Guan 已提交
59
  SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen);
S
Shengliang Guan 已提交
60 61
  pReq->type = TSDB_MGMT_TABLE_ACCT;

S
Shengliang Guan 已提交
62
  SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_SHOW, pReq, contLen);
S
Shengliang Guan 已提交
63
  ASSERT_NE(pMsg, nullptr);
S
Shengliang Guan 已提交
64
  ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
S
Shengliang Guan 已提交
65
}