test(tutorial): cover malformed tutorial.yaml -> WorldLoadException
This commit is contained in:
@@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test;
|
||||
import thb.jeanluc.adventure.model.Tutorial;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
class TutorialLoaderTest {
|
||||
|
||||
@@ -24,4 +25,11 @@ class TutorialLoaderTest {
|
||||
assertThat(t.isEmpty()).isTrue();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
5
Semesterprojekt/src/test/resources/badtut/tutorial.yaml
Normal file
5
Semesterprojekt/src/test/resources/badtut/tutorial.yaml
Normal 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"
|
||||
Reference in New Issue
Block a user