TDengine/source/dnode/mgmt/impl/test/acct/acct.cpp

67 lines
1.7 KiB
C++
Raw Normal View History

2021-12-16 09:05:13 +00:00
/**
2021-12-16 12:16:35 +00:00
* @file acct.cpp
2021-12-16 09:05:13 +00:00
* @author slguan (slguan@taosdata.com)
2021-12-16 09:07:40 +00:00
* @brief DNODE module acct-msg tests
2021-12-16 09:05:13 +00:00
* @version 0.1
* @date 2021-12-15
2021-12-06 08:19:12 +00:00
*
2021-12-16 09:05:13 +00:00
* @copyright Copyright (c) 2021
2021-12-06 08:19:12 +00:00
*
*/
2021-12-22 07:39:32 +00:00
#include "base.h"
2021-12-06 08:19:12 +00:00
class DndTestAcct : public ::testing::Test {
protected:
2021-12-22 07:39:32 +00:00
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_acct", 9012); }
static void TearDownTestSuite() { test.Cleanup(); }
2021-12-06 08:19:12 +00:00
2021-12-22 07:39:32 +00:00
static Testbase test;
2021-12-06 08:19:12 +00:00
2021-12-22 07:39:32 +00:00
public:
void SetUp() override {}
void TearDown() override {}
};
2021-12-06 08:19:12 +00:00
2021-12-22 08:38:20 +00:00
Testbase DndTestAcct::test;
2021-12-22 07:39:32 +00:00
TEST_F(DndTestAcct, 01_CreateAcct) {
int32_t contLen = sizeof(SCreateAcctMsg);
2021-12-06 08:19:12 +00:00
2021-12-22 07:39:32 +00:00
SCreateAcctMsg* pReq = (SCreateAcctMsg*)rpcMallocCont(contLen);
2021-12-06 08:19:12 +00:00
2021-12-24 07:00:51 +00:00
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_ACCT, pReq, contLen);
2021-12-06 08:19:12 +00:00
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
}
2021-12-16 06:02:39 +00:00
TEST_F(DndTestAcct, 02_AlterAcct) {
2021-12-22 07:39:32 +00:00
int32_t contLen = sizeof(SCreateAcctMsg);
2021-12-06 08:19:12 +00:00
2021-12-22 07:39:32 +00:00
SAlterAcctMsg* pReq = (SAlterAcctMsg*)rpcMallocCont(contLen);
2021-12-06 08:19:12 +00:00
2021-12-24 07:00:51 +00:00
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_ACCT, pReq, contLen);
2021-12-06 08:19:12 +00:00
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
}
2021-12-16 06:02:39 +00:00
TEST_F(DndTestAcct, 03_DropAcct) {
2021-12-22 07:39:32 +00:00
int32_t contLen = sizeof(SDropAcctMsg);
2021-12-06 08:19:12 +00:00
2021-12-22 07:39:32 +00:00
SDropAcctMsg* pReq = (SDropAcctMsg*)rpcMallocCont(contLen);
2021-12-06 08:19:12 +00:00
2021-12-24 07:00:51 +00:00
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_ACCT, pReq, contLen);
2021-12-06 08:19:12 +00:00
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
}
2021-12-16 06:02:39 +00:00
TEST_F(DndTestAcct, 04_ShowAcct) {
2021-12-22 07:39:32 +00:00
int32_t contLen = sizeof(SShowMsg);
2021-12-06 08:19:12 +00:00
2021-12-22 07:39:32 +00:00
SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen);
2021-12-06 08:19:12 +00:00
pReq->type = TSDB_MGMT_TABLE_ACCT;
2021-12-24 07:00:51 +00:00
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_SHOW, pReq, contLen);
2021-12-06 08:19:12 +00:00
ASSERT_NE(pMsg, nullptr);
2021-12-22 08:38:20 +00:00
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
2021-12-06 08:19:12 +00:00
}