update_engine: Test update_engine printouts

These tests are added to enforce sensitive variables stay invariant
with no room or future mistakes to occur again on breaking autotest
and cros flash process.

BUG=chromium:871340
TEST=FEATURES="test" emerge-$BOARD update_engine update_engine-client
TEST=/usr/bin/update_engine_client --status
TEST=cros flash $TEST_IP ../build/image/... # works

Change-Id: Ibcce5c1dee56cf5bca201a86a143a87b033605bc
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1732410
Tested-by: Jae Hoon Kim <kimjae@chromium.org>
Auto-Submit: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
diff --git a/update_status_utils_unittest.cc b/update_status_utils_unittest.cc
new file mode 100644
index 0000000..dbd80d7
--- /dev/null
+++ b/update_status_utils_unittest.cc
@@ -0,0 +1,59 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "update_engine/update_status_utils.h"
+
+#include <string>
+
+#include <gtest/gtest.h>
+
+using std::string;
+
+namespace chromeos_update_engine {
+
+TEST(UpdateStatusUtilsTest, UpdateEngineStatusToStringDefaultTest) {
+  string print =
+      R"(CURRENT_OP=UPDATE_STATUS_IDLE
+IS_INSTALL=false
+LAST_CHECKED_TIME=0
+NEW_SIZE=0
+NEW_VERSION=
+PROGRESS=0.0
+)";
+  EXPECT_EQ(print, UpdateEngineStatusToString({}));
+}
+
+TEST(UpdateStatusUtilsTest, UpdateEngineStatusToStringTest) {
+  update_engine::UpdateEngineStatus update_engine_status = {
+      .status = update_engine::UpdateStatus::CHECKING_FOR_UPDATE,
+      .is_install = true,
+      .last_checked_time = 156000000,
+      .new_size_bytes = 888,
+      .new_version = "12345.0.0",
+      .progress = 0.5,
+  };
+  string print =
+      R"(CURRENT_OP=UPDATE_STATUS_CHECKING_FOR_UPDATE
+IS_INSTALL=true
+LAST_CHECKED_TIME=156000000
+NEW_SIZE=888
+NEW_VERSION=12345.0.0
+PROGRESS=0.5
+)";
+  EXPECT_EQ(print, UpdateEngineStatusToString(update_engine_status));
+}
+
+}  // namespace chromeos_update_engine