Skip to content

Commit

Permalink
Revert TempDir
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoox committed Sep 26, 2022
1 parent fb6a18f commit 9e4d658
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

Expand All @@ -64,6 +63,7 @@
import com.linecorp.centraldogma.server.MirrorException;
import com.linecorp.centraldogma.server.MirroringService;
import com.linecorp.centraldogma.server.storage.project.Project;
import com.linecorp.centraldogma.testing.internal.TemporaryFolderExtension;
import com.linecorp.centraldogma.testing.internal.TestUtil;
import com.linecorp.centraldogma.testing.junit.CentralDogmaExtension;

Expand Down Expand Up @@ -93,8 +93,14 @@ static void init() {
mirroringService = dogma.mirroringService();
}

@TempDir
File gitRepoDir;
@RegisterExtension
final TemporaryFolderExtension gitRepoDir = new TemporaryFolderExtension() {
@Override
protected boolean runForEachTest() {
return true;
}
};

private Git git;
private File gitWorkTree;
private String gitUri;
Expand All @@ -104,7 +110,7 @@ static void init() {
@BeforeEach
void initGitRepo(TestInfo testInfo) throws Exception {
final String repoName = TestUtil.normalizedDisplayName(testInfo);
gitWorkTree = new File(gitRepoDir, repoName).getAbsoluteFile();
gitWorkTree = new File(gitRepoDir.getRoot().toFile(), repoName).getAbsoluteFile();
final Repository gitRepo = new FileRepositoryBuilder().setWorkTree(gitWorkTree).build();
createGitRepo(gitRepo);

Expand Down Expand Up @@ -328,7 +334,7 @@ void remoteToLocal_submodule(TestInfo testInfo) throws Exception {
// Create a new repository for a submodule.
final String submoduleName = TestUtil.normalizedDisplayName(testInfo) + ".submodule";
final File gitSubmoduleWorkTree =
new File(gitRepoDir, submoduleName).getAbsoluteFile();
new File(gitRepoDir.getRoot().toFile(), submoduleName).getAbsoluteFile();
final Repository gitSubmoduleRepo =
new FileRepositoryBuilder().setWorkTree(gitSubmoduleWorkTree).build();
createGitRepo(gitSubmoduleRepo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

Expand All @@ -68,6 +67,7 @@
import com.linecorp.centraldogma.server.internal.mirror.MirrorState;
import com.linecorp.centraldogma.server.mirror.MirrorDirection;
import com.linecorp.centraldogma.server.storage.project.Project;
import com.linecorp.centraldogma.testing.internal.TemporaryFolderExtension;
import com.linecorp.centraldogma.testing.internal.TestUtil;
import com.linecorp.centraldogma.testing.junit.CentralDogmaExtension;

Expand Down Expand Up @@ -99,8 +99,13 @@ static void init() {
mirroringService = dogma.mirroringService();
}

@TempDir
File gitRepoDir;
@RegisterExtension
final TemporaryFolderExtension gitRepoDir = new TemporaryFolderExtension() {
@Override
protected boolean runForEachTest() {
return true;
}
};

private Git git;
private File gitWorkTree;
Expand All @@ -111,7 +116,7 @@ static void init() {
@BeforeEach
void initGitRepo(TestInfo testInfo) throws Exception {
final String repoName = TestUtil.normalizedDisplayName(testInfo);
gitWorkTree = new File(gitRepoDir, repoName).getAbsoluteFile();
gitWorkTree = new File(gitRepoDir.getRoot().toFile(), repoName).getAbsoluteFile();
final Repository gitRepo = new FileRepositoryBuilder().setWorkTree(gitWorkTree).build();
createGitRepo(gitRepo);

Expand Down

0 comments on commit 9e4d658

Please sign in to comment.