1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-07 00:35:37 +02:00

Improve protocol handlers.

Make protocol handlers have one function per command. This allows the logic of finding the handler to be in ProtocolServer, isolates each command to a function, and removes the need to test the "not found" condition for each handler.
This commit is contained in:
David Steele
2021-03-16 13:09:34 -04:00
committed by GitHub
parent b1d945ebb7
commit 2016fac0d9
34 changed files with 866 additions and 611 deletions

View File

@ -876,7 +876,7 @@ testRun(void)
}
// *****************************************************************************************************************************
if (testBegin("verifyFile(), verifyProtocol()"))
if (testBegin("verifyFile() and verifyFileProtocol()"))
{
// Load Parameters
StringList *argList = strLstDup(argListBase);
@ -912,7 +912,7 @@ testRun(void)
"file encrypted compressed checksum mismatch");
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("verifyProtocol()");
TEST_TITLE("verifyFileProtocol()");
// Start a protocol server to test the protocol directly
Buffer *serverWrite = bufNew(8192);
@ -927,11 +927,9 @@ testRun(void)
varLstAdd(paramList, varNewUInt64(fileSize));
varLstAdd(paramList, varNewStrZ("pass"));
TEST_RESULT_BOOL(verifyProtocol(PROTOCOL_COMMAND_VERIFY_FILE_STR, paramList, server), true, "protocol verify file");
TEST_RESULT_VOID(verifyFileProtocol(paramList, server), "protocol verify file");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":0}\n", "check result");
bufUsedSet(serverWrite, 0);
TEST_RESULT_BOOL(verifyProtocol(strNew(BOGUS_STR), paramList, server), false, "invalid protocol function");
}
// *****************************************************************************************************************************