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"));
}
}
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()))));
}
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));
}
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"));
}
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"));
}
Aggregations