Skip to content

Commit

Permalink
test: replace double assertion assertThrows and assertThat with singl…
Browse files Browse the repository at this point in the history
…e assertj's assertThatIOException in RegistryServiceTest (#2741)
  • Loading branch information
carloronconi authored Feb 28, 2024
1 parent 509f138 commit 8c4b4e6
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.Properties;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.assertj.core.api.Assertions.assertThatIOException;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
Expand Down Expand Up @@ -64,11 +64,10 @@ void setUp() {

@Test
void pullImageWithPolicy_pullPolicyNeverAndNoImage_shouldThrowException() {
// When
final IOException result = assertThrows(IOException.class, () -> registryService.pullImageWithPolicy("image",
ImagePullManager.createImagePullManager("Never", "", new Properties()), null, null));
// Then
assertThat(result).hasMessageStartingWith("No image 'image' found and pull policy 'Never' is set");
assertThatIOException()
.isThrownBy(() -> registryService.pullImageWithPolicy("image",
ImagePullManager.createImagePullManager("Never", "", new Properties()), null, null))
.withMessageStartingWith("No image 'image' found and pull policy 'Never' is set");
}

@Test
Expand Down

0 comments on commit 8c4b4e6

Please sign in to comment.