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
Testbase DndTestAcct::test;

S
Shengliang Guan 已提交
28 29
TEST_F(DndTestAcct, 01_CreateAcct) {
  int32_t contLen = sizeof(SCreateAcctMsg);
S
Shengliang Guan 已提交
30

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

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

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

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

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

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

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

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

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

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

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