use of com.thoughtworks.go.server.view.artifacts.ArtifactDirectoryChooser in project gocd by gocd.
the class ArtifactsServiceTest method shouldLogAndIgnoreExceptionsWhenDeletingStageArtifacts.
@Test
void shouldLogAndIgnoreExceptionsWhenDeletingStageArtifacts() throws IllegalArtifactLocationException {
ArtifactsService artifactsService = new ArtifactsService(resolverService, stageService, artifactsDirHolder, zipUtil);
Stage stage = StageMother.createPassedStage("pipeline", 10, "stage", 20, "job", new Date());
ArtifactDirectoryChooser chooser = mock(ArtifactDirectoryChooser.class);
ReflectionUtil.setField(artifactsService, "chooser", chooser);
when(chooser.findArtifact(any(LocatableEntity.class), eq(""))).thenThrow(new IllegalArtifactLocationException("holy cow!"));
try (LogFixture logFixture = logFixtureFor(ArtifactsService.class, Level.DEBUG)) {
artifactsService.purgeArtifactsForStage(stage);
assertThat(logFixture.contains(Level.ERROR, "Error occurred while clearing artifacts for 'pipeline/10/stage/20'. Error: 'holy cow!'")).isTrue();
}
verify(stageService).markArtifactsDeletedFor(stage);
}
Aggregations