test(tutorial): cover malformed tutorial.yaml -> WorldLoadException

This commit is contained in:
2026-06-01 21:40:06 +02:00
parent 91f79b1537
commit dbfdf86810
2 changed files with 13 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test;
import thb.jeanluc.adventure.model.Tutorial; import thb.jeanluc.adventure.model.Tutorial;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
class TutorialLoaderTest { class TutorialLoaderTest {
@@ -24,4 +25,11 @@ class TutorialLoaderTest {
assertThat(t.isEmpty()).isTrue(); assertThat(t.isEmpty()).isTrue();
assertThat(t.steps()).isEmpty(); assertThat(t.steps()).isEmpty();
} }
@Test
void malformedFileThrowsWorldLoadException() {
// /badtut/tutorial.yaml has 'steps: 12345' (scalar where a list is required)
assertThatThrownBy(() -> new TutorialLoader("/badtut").load())
.isInstanceOf(WorldLoadException.class);
}
} }

View File

@@ -0,0 +1,5 @@
# Malformed on purpose: 'steps' must be a list, not a scalar.
# Used by TutorialLoaderTest to verify parse errors become WorldLoadException.
intro: "bad"
steps: 12345
closingTips: "bad"