buffet: Crash on detecting duplicate command definitions

BUG=chromium:448815
TEST=unittests, buffet_BasicDBusAPI still passes, indicating the daemon
starts up and runs correctly.

Change-Id: I5bee8f8538735b9294d239514d197ea46f17ff79
Reviewed-on: https://chromium-review.googlesource.com/240818
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Anton Muhin <antonm@chromium.org>
diff --git a/buffet/commands/command_dictionary_unittest.cc b/buffet/commands/command_dictionary_unittest.cc
index 10e7ec9..0519d88 100644
--- a/buffet/commands/command_dictionary_unittest.cc
+++ b/buffet/commands/command_dictionary_unittest.cc
@@ -107,18 +107,16 @@
   error.reset();
 }
 
-TEST(CommandDictionary, LoadCommands_RedefineInDifferentCategory) {
+TEST(CommandDictionaryDeathTest, LoadCommands_RedefineInDifferentCategory) {
   // Redefine commands in different category.
   buffet::CommandDictionary dict;
   chromeos::ErrorPtr error;
   auto json = CreateDictionaryValue(
       "{'robot':{'jump':{'parameters':{},'results':{}}}}");
   dict.LoadCommands(*json, "category1", nullptr, &error);
-  EXPECT_FALSE(dict.LoadCommands(*json, "category2", nullptr, &error));
-  EXPECT_EQ("duplicate_command_definition", error->GetCode());
-  EXPECT_EQ("Definition for command 'robot.jump' overrides an earlier "
-            "definition in category 'category1'", error->GetMessage());
-  error.reset();
+  ASSERT_DEATH(dict.LoadCommands(*json, "category2", nullptr, &error),
+               ".*Definition for command 'robot.jump' overrides an "
+               "earlier definition in category 'category1'");
 }
 
 TEST(CommandDictionary, LoadCommands_CustomCommandNaming) {