mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-21 15:59:48 +01:00
Retry failing integration tests
This uses 'RetryingTest' from junit jupiter to retry integration tests that are known to fail from time to time. We explicitly mark single tests in contrast to set a global retry to be able to trace those, whenever this is intended. To do so, we have to update to the latest version of JUnit. Unfortunately, this brought a new behaviour for the @TempDir annotation: In contrast to the former behaviour where for one test all annotated parameters got the same directory, in the new version the parameters get different directories assigned. This led to the need of some consolidation between @BeforeEach methods and the related tests. Committed-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com> Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com>
This commit is contained in:
committed by
SCM-Manager
parent
796330f883
commit
68110ee6b3
@@ -41,7 +41,6 @@ import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryLocationResolver;
|
||||
import sonia.scm.repository.RepositoryManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -72,15 +71,18 @@ class GitRepositoryContextResolverTest {
|
||||
@Nested
|
||||
class WithRepository {
|
||||
|
||||
@TempDir
|
||||
Path repositoryPath;
|
||||
|
||||
@BeforeEach
|
||||
void mockRepository(@TempDir Path repositoryPath) throws IOException {
|
||||
void mockRepository() {
|
||||
when(scmConfiguration.getBaseUrl()).thenReturn("https://hog.hitchhiker.com/scm");
|
||||
when(repositoryManager.get(new NamespaceAndName("space", "X"))).thenReturn(REPOSITORY);
|
||||
when(locationResolver.forClass(any()).getLocation("id")).thenReturn(repositoryPath);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldResolveCorrectRepository(@TempDir Path repositoryPath) {
|
||||
void shouldResolveCorrectRepository() {
|
||||
RepositoryContext context = resolver.resolve(new String[]{"git", "repo/space/X/something/else"});
|
||||
|
||||
assertThat(context.getRepository()).isSameAs(REPOSITORY);
|
||||
@@ -88,7 +90,7 @@ class GitRepositoryContextResolverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldResolveCorrectRepositoryWithContextPath(@TempDir Path repositoryPath) throws IOException {
|
||||
void shouldResolveCorrectRepositoryWithContextPath() {
|
||||
RepositoryContext context = resolver.resolve(new String[]{"git", "scm/repo/space/X/something/else"});
|
||||
|
||||
assertThat(context.getRepository()).isSameAs(REPOSITORY);
|
||||
|
||||
@@ -58,13 +58,16 @@ class GitV2UpdateStepTest {
|
||||
@InjectMocks
|
||||
GitV2UpdateStep updateStep;
|
||||
|
||||
@TempDir
|
||||
Path temp;
|
||||
|
||||
@BeforeEach
|
||||
void createDataDirectory(@TempDir Path temp) throws IOException {
|
||||
void createDataDirectory() throws IOException {
|
||||
Files.createDirectories(temp.resolve("data"));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void initRepositoryFolder(@TempDir Path temp) {
|
||||
void initRepositoryFolder() {
|
||||
when(locationResolver.forClass(Path.class)).thenReturn(locationResolverInstance);
|
||||
when(repositoryMetadataAccess.read(temp)).thenReturn(new Repository("123", "git", "space", "X"));
|
||||
doAnswer(invocation -> {
|
||||
@@ -74,14 +77,14 @@ class GitV2UpdateStepTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldWriteConfigFileForBareRepositories(@TempDir Path temp) {
|
||||
void shouldWriteConfigFileForBareRepositories() {
|
||||
updateStep.doUpdate();
|
||||
|
||||
assertThat(temp.resolve("data").resolve("config")).exists();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldWriteConfigFileForNonBareRepositories(@TempDir Path temp) throws IOException {
|
||||
void shouldWriteConfigFileForNonBareRepositories() throws IOException {
|
||||
Files.createDirectories(temp.resolve("data").resolve(".git"));
|
||||
|
||||
updateStep.doUpdate();
|
||||
|
||||
Reference in New Issue
Block a user