diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-12-23 11:13:24 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-12-23 11:13:24 +0000 |
| commit | d22dab1ccfe55ee2f3449bb9065481803f8dc0ff (patch) | |
| tree | 700450a458c1e7bef19f9865ada88bd77d100948 /src/test/java | |
| parent | 39ab36c7a288e8ccf1203f8bb828f97e6aa025ea (diff) | |
Check type of example and profile elements
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/config/ProjectConfigTests.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/config/ProjectConfigTests.java b/src/test/java/org/shedlang/compiler/config/ProjectConfigTests.java index b08fa78a..10397acf 100644 --- a/src/test/java/org/shedlang/compiler/config/ProjectConfigTests.java +++ b/src/test/java/org/shedlang/compiler/config/ProjectConfigTests.java @@ -178,6 +178,24 @@ public class ProjectConfigTests { } @Test + public void whenProjectConfigHasExampleThatIsntTableThenErrorIsThrown() { + var error = assertThrows( + ConfigError.class, + () -> ProjectConfig.fromString(PROJECT_PATH, """ + [shed] + examples = [1]""" + ) + ); + + assertThat(error.getMessage(), equalTo("Expected shed.examples[0] to be a table, but was Long")); + assertThat(error.source().describe(), equalTo(""" + <string>:2:13 + examples = [1] + ^""" + )); + } + + @Test public void canParseProjectConfigWithNoProfiles() { var config = ProjectConfig.fromString(PROJECT_PATH, ""); @@ -223,4 +241,22 @@ public class ProjectConfigTests { ^""" )); } + + @Test + public void whenProjectConfigHasProfileThatIsntTableThenErrorIsThrown() { + var error = assertThrows( + ConfigError.class, + () -> ProjectConfig.fromString(PROJECT_PATH, """ + [shed] + profiles = [1]""" + ) + ); + + assertThat(error.getMessage(), equalTo("Expected shed.profiles[0] to be a table, but was Long")); + assertThat(error.source().describe(), equalTo(""" + <string>:2:13 + profiles = [1] + ^""" + )); + } } |
