peridot/lib/modular_config/modular_config_unittest.cc
// Test that ModularConfigReader finds and reads the AgentServiceIndex.
Test that ModularConfigReader finds and reads the AgentServiceIndex.
Test that ModularConfigReader finds and reads the AgentServiceIndex .
TEST_F(ModularConfigReaderTest, ProvideAgentServiceIndex) {
  const std::string kServiceNameForTest = "fuchsia.modular.ModularConfigReaderTest";
  const std::string kAgentUrlForTest =
      "fuchsia-pkg://example.com/ModularConfigReaderTest#meta/"
      "ModularConfigReaderTest.cmx";
  const std::string service_name_0 = kServiceNameForTest + "0";
  const std::string agent_url_0 = kAgentUrlForTest + "0";
  const std::string service_name_1 = kServiceNameForTest + "1";
  const std::string agent_url_1 = kAgentUrlForTest + "1";
  std::string config_contents = fxl::Substitute(
      R"({
        "basemgr": {
        },
        "sessionmgr": {
          "agent_service_index": [
            {
              "service_name": "$0",
              "agent_url": "$1"
            },
            {
              "service_name": "$2",
              "agent_url": "$3"
            }
          ]
        }
      })",
      service_name_0, agent_url_0, service_name_1, agent_url_1);
  modular::PseudoDirServer server(modular::MakeFilePathWithContents(
      files::JoinPath(modular_config::kOverriddenConfigDir, modular_config::kStartupConfigFilePath),
      config_contents));
  modular::ModularConfigReader reader(server.OpenAt("."));
  auto config = reader.GetSessionmgrConfig();
  EXPECT_EQ(service_name_0, config.agent_service_index().at(0).service_name());
  EXPECT_EQ(agent_url_0, config.agent_service_index().at(0).agent_url());
  EXPECT_EQ(service_name_1, config.agent_service_index().at(1).service_name());
  EXPECT_EQ(agent_url_1, config.agent_service_index().at(1).agent_url());
}
TEST_F ( ModularConfigReaderTest , ProvideAgentServiceIndex ) { const std :: string kServiceNameForTest = " " ; const std :: string kAgentUrlForTest = " " " " ; const std :: string service_name_0 = kServiceNameForTest + " " ; const std :: string agent_url_0 = kAgentUrlForTest + " " ; const std :: string service_name_1 = kServiceNameForTest + " " ; const std :: string agent_url_1 = kAgentUrlForTest + " " ; std :: string config_contents = fxl :: Substitute ( R" ( {
        "basemgr": {
        },
        "sessionmgr": {
          "agent_service_index": [
            {
              "service_name": "$0",
              "agent_url": "$1"
            },
            {
              "service_name": "$2",
              "agent_url": "$3"
            }
          ]
        }
      } ) " , service_name_0 , agent_url_0 , service_name_1 , agent_url_1 ) ; modular :: PseudoDirServer server ( modular :: MakeFilePathWithContents ( files :: JoinPath ( modular_config :: kOverriddenConfigDir , modular_config :: kStartupConfigFilePath ) , config_contents ) ) ; modular :: ModularConfigReader reader ( server . OpenAt ( " " ) ) ; auto config = reader . GetSessionmgrConfig ( ) ; EXPECT_EQ ( service_name_0 , config . agent_service_index ( ) . at ( 0 ) . service_name ( ) ) ; EXPECT_EQ ( agent_url_0 , config . agent_service_index ( ) . at ( 0 ) . agent_url ( ) ) ; EXPECT_EQ ( service_name_1 , config . agent_service_index ( ) . at ( 1 ) . service_name ( ) ) ; EXPECT_EQ ( agent_url_1 , config . agent_service_index ( ) . at ( 1 ) . agent_url ( ) ) ; }
Test that ModularConfigReader finds and reads the AgentServiceIndex.
Test that ModularConfigReader finds and reads the AgentServiceIndex .
// Verify that ModularConfigReader parsed the config values we gave it.