@@ -42,8 +42,8 @@ bool CreateFileAt(int root_fd, const std::string& path, std::string_view data) {
42
42
class ModularConfigReaderTest : public gtest ::RealLoopFixture {};
43
43
class ModularConfigWriterTest : public gtest ::RealLoopFixture {};
44
44
45
- // Test that ModularConfigReader finds and reads the startup.config file given a
46
- // root directory that contains config data .
45
+ // Test that ModularConfigReader finds and reads the startup.config file from the overridden
46
+ // config directory .
47
47
TEST_F (ModularConfigReaderTest, OverrideConfigDir) {
48
48
constexpr char kSessionShellForTest [] =
49
49
" fuchsia-pkg://example.com/ModularConfigReaderTest#meta/"
@@ -62,8 +62,35 @@ TEST_F(ModularConfigReaderTest, OverrideConfigDir) {
62
62
kSessionShellForTest );
63
63
64
64
modular::PseudoDirServer server (modular::MakeFilePathWithContents (
65
- files::JoinPath (modular_config::kOverriddenConfigDir , modular_config::kStartupConfigFilePath ),
66
- config_contents));
65
+ modular::ModularConfigReader::GetOverriddenConfigPath (), config_contents));
66
+
67
+ modular::ModularConfigReader reader (server.OpenAt (" ." ));
68
+ auto config = reader.GetBasemgrConfig ();
69
+
70
+ // Verify that ModularConfigReader parsed the config value we gave it.
71
+ EXPECT_EQ (kSessionShellForTest , config.session_shell_map ().at (0 ).config ().app_config ().url ());
72
+ }
73
+
74
+ // Test that ModularConfigReader finds and reads the startup.config file in the package directory.
75
+ TEST_F (ModularConfigReaderTest, PackagedConfigDir) {
76
+ constexpr char kSessionShellForTest [] =
77
+ " fuchsia-pkg://example.com/ModularConfigReaderTest#meta/"
78
+ " ModularConfigReaderTest.cmx" ;
79
+
80
+ std::string config_contents = fxl::Substitute (
81
+ R"( {
82
+ "basemgr": {
83
+ "session_shells": [
84
+ {
85
+ "url": "$0"
86
+ }
87
+ ]
88
+ }
89
+ })" ,
90
+ kSessionShellForTest );
91
+
92
+ modular::PseudoDirServer server (modular::MakeFilePathWithContents (
93
+ modular::ModularConfigReader::GetPackagedConfigPath (), config_contents));
67
94
68
95
modular::ModularConfigReader reader (server.OpenAt (" ." ));
69
96
auto config = reader.GetBasemgrConfig ();
@@ -160,8 +187,7 @@ TEST_F(ModularConfigReaderTest, GetConfigAsString) {
160
187
161
188
// Host |config_contents|, parse it into |first_reader|, and write configs into |read_config_str|
162
189
modular::PseudoDirServer server (modular::MakeFilePathWithContents (
163
- files::JoinPath (modular_config::kDefaultConfigDir , modular_config::kStartupConfigFilePath ),
164
- config_contents));
190
+ modular::ModularConfigReader::GetConfigDataConfigPath (), config_contents));
165
191
166
192
modular::ModularConfigReader first_reader (server.OpenAt (" ." ));
167
193
auto basemgr_config = first_reader.GetBasemgrConfig ();
@@ -171,8 +197,7 @@ TEST_F(ModularConfigReaderTest, GetConfigAsString) {
171
197
172
198
// Host the new config string and parse it into |second_reader|
173
199
modular::PseudoDirServer server_after_read (modular::MakeFilePathWithContents (
174
- files::JoinPath (modular_config::kDefaultConfigDir , modular_config::kStartupConfigFilePath ),
175
- read_config_str));
200
+ modular::ModularConfigReader::GetConfigDataConfigPath (), read_config_str));
176
201
177
202
modular::ModularConfigReader second_reader (server_after_read.OpenAt (" ." ));
178
203
@@ -436,7 +461,7 @@ TEST_F(ModularConfigReaderTest, ReadPersistentConfig) {
436
461
437
462
// The /config/data/startup.config file contains an empty config.
438
463
ASSERT_TRUE (
439
- CreateFileAt (root_fd.get (), modular::ModularConfigReader::GetDefaultConfigPath (), " {}" ));
464
+ CreateFileAt (root_fd.get (), modular::ModularConfigReader::GetConfigDataConfigPath (), " {}" ));
440
465
441
466
// Allow persistent config_override.
442
467
ASSERT_TRUE (CreateFileAt (root_fd.get (),
0 commit comments