Skip to content

Commit

Permalink
fix: register test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aritosteles committed Sep 25, 2024
1 parent ce5780e commit 8f38f93
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/agent/tests/register_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class RegisterTest : public ::testing::Test

MockHttpClient mockHttpClient;
std::unique_ptr<AgentInfo> agent;
registration::UserCredentials userCredentials {"user", "password"};
agent_registration::UserCredentials userCredentials {"user", "password"};
};

TEST_F(RegisterTest, RegistrationTestSuccess)
Expand All @@ -84,7 +84,9 @@ TEST_F(RegisterTest, RegistrationTestSuccess)
EXPECT_CALL(mockHttpClient, PerformHttpRequest(testing::Eq(reqParams))).WillOnce(testing::Return(expectedResponse));

// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
const bool res = registration::RegisterAgent(userCredentials, mockHttpClient);
agent_registration::AgentRegistration reg(
userCredentials.user, userCredentials.password, "agent_key", "agent_name");
const bool res = reg.SendRegistration();
ASSERT_TRUE(res);
}

Expand All @@ -94,7 +96,9 @@ TEST_F(RegisterTest, RegistrationFailsIfAuthenticationFails)
.WillOnce(testing::Return(std::nullopt));

// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
const bool res = registration::RegisterAgent(userCredentials, mockHttpClient);
agent_registration::AgentRegistration reg(
userCredentials.user, userCredentials.password, "agent_key", "agent_name");
const bool res = reg.SendRegistration();
ASSERT_FALSE(res);
}

Expand All @@ -110,7 +114,9 @@ TEST_F(RegisterTest, RegistrationFailsIfServerResponseIsNotOk)
EXPECT_CALL(mockHttpClient, PerformHttpRequest(testing::_)).WillOnce(testing::Return(expectedResponse));

// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
const bool res = registration::RegisterAgent(userCredentials, mockHttpClient);
agent_registration::AgentRegistration reg(
userCredentials.user, userCredentials.password, "agent_key", "agent_name");
const bool res = reg.SendRegistration();
ASSERT_FALSE(res);
}

Expand Down

0 comments on commit 8f38f93

Please sign in to comment.