Fix aos cli autocomplete config check
ReadConfig does the work of finding the config path, so it shouldn't be
assumed to be in the current directory.
Signed-off-by: Milind Upadhyay <milind.upadhyay@gmail.com>
Change-Id: I20552dfc002bfd6235dd2ac981d1d8ee245bd2e9
Signed-off-by: milind-u <milind.upadhyay@gmail.com>
diff --git a/aos/configuration_test.cc b/aos/configuration_test.cc
index f5081d2..b493058 100644
--- a/aos/configuration_test.cc
+++ b/aos/configuration_test.cc
@@ -95,6 +95,23 @@
"aos/testdata/config1_bad.json");
}
+// Tests that we die when we give an invalid path.
+TEST_F(ConfigurationDeathTest, NonexistentFile) {
+ EXPECT_DEATH(
+ {
+ FlatbufferDetachedBuffer<Configuration> config =
+ ReadConfig("nonexistent/config.json");
+ },
+ "above error");
+}
+
+// Tests that we return std::nullopt when we give an invalid path.
+TEST_F(ConfigurationTest, NonexistentFileOptional) {
+ std::optional<FlatbufferDetachedBuffer<Configuration>> config =
+ MaybeReadConfig("nonexistent/config.json");
+ EXPECT_FALSE(config.has_value());
+}
+
// Tests that we reject invalid channel names. This means any channels with //
// in their name, a trailing /, or regex characters.
TEST_F(ConfigurationDeathTest, InvalidChannelName) {
@@ -891,8 +908,8 @@
TEST_F(ConfigurationDeathTest, InvalidLoggerConfig) {
EXPECT_DEATH(
{
- FlatbufferDetachedBuffer<Configuration> config =
- ReadConfig(ArtifactPath("aos/testdata/invalid_logging_configuration.json"));
+ FlatbufferDetachedBuffer<Configuration> config = ReadConfig(
+ ArtifactPath("aos/testdata/invalid_logging_configuration.json"));
},
"Logging timestamps without data");
}