From 237dde60697cb1fd8b0336685cf39d7f1a515535 Mon Sep 17 00:00:00 2001 From: Andre Detsch Date: Fri, 12 Jul 2024 14:27:44 -0300 Subject: [PATCH] tests: Add CheckInCurrent basic test Signed-off-by: Andre Detsch --- tests/apiclient_test.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/apiclient_test.cc b/tests/apiclient_test.cc index 788c701d..74d9c023 100644 --- a/tests/apiclient_test.cc +++ b/tests/apiclient_test.cc @@ -562,6 +562,30 @@ TEST_F(ApiClientTest, InstallTargetWithHackedApps) { ASSERT_EQ(nullptr, installer); } +TEST_F(ApiClientTest, CheckInCurrent) { + auto lite_client = createLiteClient(InitialVersion::kOn); + AkliteClient client(lite_client); + auto result = client.CheckIn(); + + auto events = getDeviceGateway().getEvents(); + ASSERT_EQ(2, events.size()); + auto val = getDeviceGateway().readSotaToml(); + ASSERT_NE(std::string::npos, val.find("[pacman]")); + + ASSERT_EQ(CheckInResult::Status::Ok, result.status); + ASSERT_EQ(1, result.Targets().size()); + + ASSERT_TRUE(getDeviceGateway().resetSotaToml()); + ASSERT_TRUE(resetEvents()); + + // No events should be generated, and no callback invoked + EXPECT_CALL(*lite_client, callback(testing::_, testing::_, testing::_)).Times(0); + result = client.CheckInCurrent(); + ASSERT_EQ(1, result.Targets().size()); + events = getDeviceGateway().getEvents(); + ASSERT_EQ(0, events.size()); +} + // Tests using Extended Aklite Client methods: TEST_F(ApiClientTest, ExtApiRollback) { auto liteclient = createLiteClient();