-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: refactor test, so that it is hopefully running on CI
- Loading branch information
Showing
3 changed files
with
23 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import com.jcraft.jsch.JSchException; | ||
import com.jcraft.jsch.Session; | ||
import org.eclipse.jgit.api.Git; | ||
import org.eclipse.jgit.api.errors.GitAPIException; | ||
import org.eclipse.jgit.transport.SshTransport; | ||
import org.eclipse.jgit.transport.ssh.jsch.JschConfigSessionFactory; | ||
import org.eclipse.jgit.transport.ssh.jsch.OpenSshConfig; | ||
|
@@ -14,10 +15,13 @@ | |
import org.junit.jupiter.api.io.TempDir; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
import org.testcontainers.shaded.org.apache.commons.io.FileUtils; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
|
@@ -32,6 +36,7 @@ public class GitServerContainerTest { | |
@TempDir(cleanup = CleanupMode.NEVER) | ||
private File tempDir; | ||
|
||
|
||
@Test | ||
void validDockerImageName() { | ||
assertThatNoException().isThrownBy(() -> | ||
|
@@ -94,8 +99,16 @@ void gitRepoURI() { | |
} | ||
|
||
@Test | ||
void copyExistingGitRepo() { | ||
var containerUnderTest = new GitServerContainer(LATEST_GIT_SERVER_VERSION).withCopyExistingGitRepoToContainer("src/test/resources/existingRepo"); | ||
void copyExistingGitRepo(@TempDir File sampleRepo) throws GitAPIException, IOException { | ||
FileUtils.copyFileToDirectory(new File("src/test/resources/sampleRepo/testFile"), sampleRepo); | ||
|
||
Git repo = Git.init().setDirectory(sampleRepo).setInitialBranch("main").call(); | ||
repo.add().addFilepattern("testFile").call(); | ||
repo.commit().setAuthor("Sandra Parsick", "[email protected]").setMessage("init").call(); | ||
|
||
var containerUnderTest = new GitServerContainer(LATEST_GIT_SERVER_VERSION) | ||
.withCopyExistingGitRepoToContainer(sampleRepo.getAbsolutePath()); | ||
|
||
containerUnderTest.start(); | ||
|
||
URI gitRepoURI = containerUnderTest.getGitRepoURIAsSSH(); | ||
|
@@ -122,10 +135,16 @@ protected void configure(OpenSshConfig.Host hc, Session session) { | |
} | ||
|
||
@Test | ||
void copyExistingGitRepoWithCustomRepoName() { | ||
void copyExistingGitRepoWithCustomRepoName(@TempDir File sampleRepo) throws IOException, GitAPIException { | ||
FileUtils.copyFileToDirectory(new File("src/test/resources/sampleRepo/testFile"), sampleRepo); | ||
|
||
Git repo = Git.init().setDirectory(sampleRepo).call(); | ||
repo.add().addFilepattern("testFile").call(); | ||
repo.commit().setAuthor("Sandra Parsick", "[email protected]").setMessage("init").call(); | ||
|
||
var containerUnderTest = new GitServerContainer(LATEST_GIT_SERVER_VERSION) | ||
.withGitRepo("customRepoName") | ||
.withCopyExistingGitRepoToContainer("src/test/resources/existingRepo"); | ||
.withCopyExistingGitRepoToContainer(sampleRepo.getAbsolutePath()); | ||
containerUnderTest.start(); | ||
|
||
URI gitRepoURI = containerUnderTest.getGitRepoURIAsSSH(); | ||
|
Submodule existingRepo
deleted from
cce45a
Empty file.