mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
Add basic integration test for interactions with repositories
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package sonia.scm.it;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assume.assumeFalse;
|
||||
import static sonia.scm.it.RestUtil.given;
|
||||
import static sonia.scm.it.ScmTypes.availableScmTypes;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class RepositoryAccessITCase {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||
|
||||
private final String repositoryType;
|
||||
private RepositoryUtil repositoryUtil;
|
||||
|
||||
public RepositoryAccessITCase(String repositoryType) {
|
||||
this.repositoryType = repositoryType;
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<String> createParameters() {
|
||||
return availableScmTypes();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void initClient() throws IOException {
|
||||
TestData.createDefault();
|
||||
repositoryUtil = new RepositoryUtil(repositoryType, tempFolder.getRoot());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindBranches() throws IOException {
|
||||
assumeFalse("There are no branches for SVN", repositoryType.equals("svn"));
|
||||
|
||||
repositoryUtil.createAndCommitFile("a.txt", "a");
|
||||
|
||||
String branchesUrl = given()
|
||||
.when()
|
||||
.get(TestData.getDefaultRepositoryUrl(repositoryType))
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_OK)
|
||||
.extract()
|
||||
.path("_links.branches.href");
|
||||
|
||||
Object branchName = given()
|
||||
.when()
|
||||
.get(branchesUrl)
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_OK)
|
||||
.extract()
|
||||
.path("_embedded.branches[0].name");
|
||||
|
||||
assertNotNull(branchName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user