Search in sources :

Example 56 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class GitCommitSupportTest method should_throw_meaningful_error_if_destination_branch_doesnt_exist.

@TestFor(issues = "TW-39051")
public void should_throw_meaningful_error_if_destination_branch_doesnt_exist() throws Exception {
    String nonExistingBranch = "refs/heads/nonExisting";
    try {
        VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryDir("merge")).withBranch(nonExistingBranch).build();
        CommitPatchBuilder patchBuilder = myCommitSupport.getCommitPatchBuilder(root);
        byte[] bytes = "test-content".getBytes();
        patchBuilder.createFile("file-to-commit", new ByteArrayInputStream(bytes));
        patchBuilder.commit(new CommitSettingsImpl("user", "Commit description"));
        patchBuilder.dispose();
        fail();
    } catch (VcsException e) {
        assertTrue(e.getMessage().contains("The '" + nonExistingBranch + "' destination branch doesn't exist"));
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TestFor(jetbrains.buildServer.util.TestFor)

Example 57 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class GitCommitSupportTest method should_canonicalize_line_endings_on_commit.

@TestFor(issues = "TW-38226")
public void should_canonicalize_line_endings_on_commit() throws Exception {
    CommitPatchBuilder patchBuilder = myCommitSupport.getCommitPatchBuilder(myRoot);
    String committedContent = "a\r\nb\r\nc\r\n";
    byte[] bytes = committedContent.getBytes();
    patchBuilder.createFile("file-to-commit", new ByteArrayInputStream(bytes));
    patchBuilder.commit(new CommitSettingsImpl("user", "Commit description"));
    patchBuilder.dispose();
    RepositoryStateData state2 = myGit.getCurrentState(myRoot);
    byte[] content = myGit.getContentProvider().getContent("file-to-commit", myRoot, state2.getBranchRevisions().get(state2.getDefaultBranchName()));
    assertEquals("Line-endings were not normalized", "a\nb\nc\n", new String(content));
    VcsRoot autoCrlfRoot = vcsRoot().withAutoCrlf(true).withFetchUrl(getRemoteRepositoryDir("merge")).build();
    assertEquals(committedContent, new String(myGit.getContentProvider().getContent("file-to-commit", autoCrlfRoot, state2.getBranchRevisions().get(state2.getDefaultBranchName()))));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TestFor(jetbrains.buildServer.util.TestFor)

Example 58 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class GitCommitSupportTest method should_create_branch_if_repository_has_no_branches.

@TestFor(issues = "TW-39051")
public void should_create_branch_if_repository_has_no_branches() throws Exception {
    String nonExistingBranch = "refs/heads/nonExisting";
    File remoteRepo = myTempFiles.createTempDir();
    Repository r = new RepositoryBuilder().setBare().setGitDir(remoteRepo).build();
    r.create(true);
    VcsRoot root = vcsRoot().withFetchUrl(remoteRepo).withBranch(nonExistingBranch).build();
    CommitPatchBuilder patchBuilder = myCommitSupport.getCommitPatchBuilder(root);
    byte[] bytes = "test-content".getBytes();
    patchBuilder.createFile("file-to-commit", new ByteArrayInputStream(bytes));
    patchBuilder.commit(new CommitSettingsImpl("user", "Commit description"));
    patchBuilder.dispose();
    RepositoryStateData state2 = myGit.getCurrentState(root);
    assertNotNull(state2.getBranchRevisions().get(nonExistingBranch));
}
Also used : Repository(org.eclipse.jgit.lib.Repository) RepositoryBuilder(org.eclipse.jgit.lib.RepositoryBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) File(java.io.File) TestFor(jetbrains.buildServer.util.TestFor)

Example 59 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class GitPatchTest method submodules_and_checkout_rules4.

@TestFor(issues = "TW-50097")
@Test(dataProvider = "patchInSeparateProcess")
public void submodules_and_checkout_rules4(boolean patchInSeparateProcess) throws Exception {
    myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
    VcsRoot root = getRoot("sub-submodule", true);
    checkPatch(root, "submodules_and_checkout_rules4", null, "ce6044093939bb47283439d97a1c80f759669ff5", new CheckoutRules("+:first-level-submodule/sub-sub/file.txt"));
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 60 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class CredentialsHelperTest method null_username.

@TestFor(issues = "TW-73873")
public void null_username() throws Exception {
    CredentialsHelperConfig config = new CredentialsHelperConfig();
    config.addCredentials("https://acme.org/user/repo.git", null, "secret");
    config.setMatchAllUrls(true);
    Map<String, String> out = run(map("protocol", "https", "host", "unknown.org", "path", "/some/path"), config.getEnv());
    then(out).contains(entry("protocol", "https"), entry("host", "unknown.org"), entry("path", "/some/path"), entry("password", "secret"));
}
Also used : CredentialsHelperConfig(jetbrains.buildServer.buildTriggers.vcs.git.command.credentials.CredentialsHelperConfig) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

TestFor (jetbrains.buildServer.util.TestFor)129 Test (org.testng.annotations.Test)81 File (java.io.File)65 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)56 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)26 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)21 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)17 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)12 VcsException (jetbrains.buildServer.vcs.VcsException)11 URIish (org.eclipse.jgit.transport.URIish)11 Repository (org.eclipse.jgit.lib.Repository)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)7 AfterMethod (org.testng.annotations.AfterMethod)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 Method (java.lang.reflect.Method)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 GitTestUtil.copyRepository (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.copyRepository)6 Build (jetbrains.buildServer.server.rest.model.build.Build)6 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)6 FileUtil.writeFile (jetbrains.buildServer.util.FileUtil.writeFile)6