Skip to content

Commit 1efadb6

Browse files
committed
Add new unit test to make sure config overrides are workign as expected
Signed-off-by: Marvin Froeder <[email protected]>
1 parent d59189c commit 1efadb6

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

sqrl-tools/sqrl-config/src/main/java/com/datasqrl/config/SqrlConfigCommons.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,6 @@ public static SqrlConfig fromFiles(ErrorCollector errors, String jsonSchemaResou
408408
NodeCombiner combiner = new OverrideCombiner();
409409
CombinedConfiguration combinedConfiguration = new CombinedConfiguration(combiner);
410410

411-
try {
412-
URL url = SqrlConfigCommons.class.getResource("/default-package.json");
413-
JSONConfiguration config = configs.fileBased(JSONConfiguration.class, url);
414-
combinedConfiguration.addConfiguration(config);
415-
} catch (ConfigurationException e) {
416-
throw errors.withConfig("Error loading default configuration").handle(e);
417-
}
418-
419411
for (int i = files.size()-1; i >= 0; i--) { //iterate backwards so last file takes precedence
420412
Path file = files.get(i);
421413
ErrorCollector localErrors = errors.withConfig(file);
@@ -428,6 +420,14 @@ public static SqrlConfig fromFiles(ErrorCollector errors, String jsonSchemaResou
428420
}
429421
}
430422

423+
try {
424+
URL url = SqrlConfigCommons.class.getResource("/default-package.json");
425+
JSONConfiguration config = configs.fileBased(JSONConfiguration.class, url);
426+
combinedConfiguration.addConfiguration(config);
427+
} catch (ConfigurationException e) {
428+
throw errors.withConfig("Error loading default configuration").handle(e);
429+
}
430+
431431
String configFilename;
432432
if (files.isEmpty()){
433433
configFilename = "default-package.json";

sqrl-tools/sqrl-config/src/test/java/com/datasqrl/config/SqrlConfigCommonsTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void givenNoPaths_whenCreatingConfig_thenReturnDefaults() {
3131
assertThat(underTest.getEngines().getEngineConfig("flink")).isPresent();
3232
assertThat(underTest.getScriptConfig().getGraphql()).isEmpty();
3333
assertThat(underTest.getScriptConfig().getMainScript()).isEmpty();
34+
assertThat(underTest.getPackageConfig().getName()).isEqualTo("datasqrl.profile.default");
3435
}
3536

3637
@Test
@@ -41,12 +42,13 @@ void givenSinglePath_whenCreatingConfig_thenOverrideDefaults() {
4142
assertThat(underTest.getVersion()).isEqualTo(1);
4243

4344
//test-package.json overrides enabled engines ONLY
44-
assertThat(underTest.getEnabledEngines()).contains("flink");
45+
assertThat(underTest.getEnabledEngines()).contains("test");
4546

4647
assertThat(underTest.getTestConfig()).isPresent();
4748
assertThat(underTest.getEngines().getEngineConfig("flink")).isPresent();
4849
assertThat(underTest.getScriptConfig().getGraphql()).isEmpty();
4950
assertThat(underTest.getScriptConfig().getMainScript()).isEmpty();
51+
assertThat(underTest.getPackageConfig().getName()).isEqualTo("datasqrl.test");
5052
}
5153

5254
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"version": "1",
3-
"enabled-engines": ["flink"]
3+
"enabled-engines": ["test"],
4+
"package": {
5+
"name": "datasqrl.test"
6+
}
47
}

0 commit comments

Comments
 (0)