Skip to content

Commit

Permalink
Add tests for app id
Browse files Browse the repository at this point in the history
  • Loading branch information
Shillaker committed Sep 8, 2021
1 parent 3ff1ed5 commit aa867c3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test/util/test_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,30 @@ TEST_CASE("Test message factory shared", "[util]")
REQUIRE(!msg->resultkey().empty());
}

TEST_CASE("Test adding id to message", "[util]")
TEST_CASE("Test adding ids to message", "[util]")
{
faabric::Message msgA;
faabric::Message msgB;

REQUIRE(msgA.id() == 0);
REQUIRE(msgA.resultkey().empty());
REQUIRE(msgA.statuskey().empty());
REQUIRE(msgA.appid() == 0);

REQUIRE(msgB.id() == 0);
REQUIRE(msgB.resultkey().empty());
REQUIRE(msgB.statuskey().empty());
REQUIRE(msgB.appid() == 0);

faabric::util::setMessageId(msgA);
faabric::util::setMessageId(msgB);

REQUIRE(msgA.id() > 0);
REQUIRE(msgA.appid() > 0);
REQUIRE(msgB.id() > 0);
REQUIRE(msgB.appid() > 0);
REQUIRE(msgB.id() > msgA.id());
REQUIRE(msgB.appid() > msgA.appid());

std::string expectedResultKeyA =
std::string("result_" + std::to_string(msgA.id()));
Expand All @@ -65,21 +70,24 @@ TEST_CASE("Test adding id to message", "[util]")
REQUIRE(msgB.statuskey() == expectedStatusKeyB);
}

TEST_CASE("Test adding ID to message with an existing ID")
TEST_CASE("Test adding ids to message with existing ids")
{
faabric::Message msg;
faabric::util::setMessageId(msg);

int originalId = msg.id();
int originalAppId = msg.appid();
std::string originalStatusKey = msg.statuskey();
std::string originalResultKey = msg.resultkey();

faabric::util::setMessageId(msg);
int afterId = msg.id();
int afterAppId = msg.appid();
std::string afterStatusKey = msg.statuskey();
std::string afterResultKey = msg.resultkey();

REQUIRE(afterId == originalId);
REQUIRE(afterAppId == originalAppId);
REQUIRE(afterStatusKey == originalStatusKey);
REQUIRE(afterResultKey == originalResultKey);
}
Expand Down

0 comments on commit aa867c3

Please sign in to comment.