diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-12-23 10:45:10 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-12-23 10:45:10 +0000 |
| commit | 50a74171bad57572bb70d78854bff177fbe206a7 (patch) | |
| tree | 8a6caf951de31bddd5752edbd8b62a0505c37405 /src/test/java | |
| parent | 9bbd81270311255f8c09e49e062ef4961368a4d2 (diff) | |
Check TOML value types when getting shed.bins
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 cedf2207..c4657487 100644 --- a/src/test/java/org/shedlang/compiler/config/ProjectConfigTests.java +++ b/src/test/java/org/shedlang/compiler/config/ProjectConfigTests.java @@ -1,6 +1,7 @@ package org.shedlang.compiler.config; import org.junit.jupiter.api.Test; +import org.shedlang.compiler.config.errors.ConfigError; import org.shedlang.compiler.config.errors.TomlSyntaxConfigError; import org.shedlang.compiler.types.NamespaceName; @@ -44,6 +45,23 @@ public class ProjectConfigTests { } @Test + public void whenProjectConfigHasShedThatArentArrayThenErrorIsThrown() { + var error = assertThrows( + ConfigError.class, + () -> ProjectConfig.fromString(PROJECT_PATH, """ + shed = true""" + ) + ); + + assertThat(error.getMessage(), equalTo("Expected shed to be a table, but was Boolean")); + assertThat(error.source().describe(), equalTo(""" + <string>:1:1 + shed = true + ^""" + )); + } + + @Test public void canParseProjectConfigWithNoBins() { var config = ProjectConfig.fromString(PROJECT_PATH, ""); @@ -77,6 +95,24 @@ public class ProjectConfigTests { } @Test + public void whenProjectConfigHasBinsThatArentArrayThenErrorIsThrown() { + var error = assertThrows( + ConfigError.class, + () -> ProjectConfig.fromString(PROJECT_PATH, """ + [shed] + bins = true""" + ) + ); + + assertThat(error.getMessage(), equalTo("Expected shed.bins to be an array, but was Boolean")); + assertThat(error.source().describe(), equalTo(""" + <string>:2:1 + bins = true + ^""" + )); + } + + @Test public void canParseProjectConfigWithNoExamples() { var config = ProjectConfig.fromString(PROJECT_PATH, ""); |
