Skip to content

Commit dfd0144

Browse files
committed
Add shouldNotCreateNewPostWhenValidationFails🫸🌀✏️📗🐧🐳⬆
1 parent c732166 commit dfd0144

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/test/java/id/my/hendisantika/testcontainerpostgresql/SpringBootTestContainerPostgresqlApplicationTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,12 @@ void shouldCreateNewPostWhenPostIsValid() {
7070
assertThat(response.getBody().title()).isEqualTo("101 Title");
7171
assertThat(response.getBody().body()).isEqualTo("101 Body");
7272
}
73+
74+
@Test
75+
void shouldNotCreateNewPostWhenValidationFails() {
76+
Post post = new Post(101, 1, "", "", null);
77+
ResponseEntity<Post> response = restTemplate.exchange("/api/posts", HttpMethod.POST, new HttpEntity<Post>(post), Post.class);
78+
79+
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
80+
}
7381
}

0 commit comments

Comments
 (0)