Search in sources :

Example 21 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class FilesInCommitIT method setUp.

@Before
public void setUp() throws Exception {
    baseConfig.setString("cache", "git_file_diff", "timeout", "1 minute");
    ObjectId headCommit = testRepo.getRepository().resolve("HEAD");
    addCommit(headCommit, ImmutableMap.of("file_1.txt", "file 1 content", "file_2.txt", "file 2 content"));
    Result result = createEmptyChange();
    changeId = result.getChangeId();
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) Result(com.google.gerrit.acceptance.PushOneCommit.Result) BinaryResult(com.google.gerrit.extensions.restapi.BinaryResult) Before(org.junit.Before)

Example 22 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class FilesInCommitIT method listFilesForMergeCommitAgainstParent1.

@Test
public void listFilesForMergeCommitAgainstParent1() throws Exception {
    PushOneCommit.Result result = createMergeCommitChange("refs/for/master", "my_file.txt");
    String changeId = result.getChangeId();
    addModifiedPatchSet(changeId, "my_file.txt", content -> content.concat("Line I\nLine II\n"));
    String lastCommitId = gApi.changes().id(changeId).get().currentRevision;
    // Diffing against the first parent.
    Map<String, FileInfo> changedFiles = gApi.projects().name(project.get()).commit(lastCommitId).files(1);
    assertThat(changedFiles.keySet()).containsExactly("/COMMIT_MSG", "/MERGE_LIST", // file bar is coming from parent two
    "bar", "my_file.txt");
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) FileInfo(com.google.gerrit.extensions.common.FileInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 23 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class FilesInCommitIT method listFilesForMergeCommitAgainstDefaultParent.

@Test
public void listFilesForMergeCommitAgainstDefaultParent() throws Exception {
    PushOneCommit.Result result = createMergeCommitChange("refs/for/master", "my_file.txt");
    String changeId = result.getChangeId();
    addModifiedPatchSet(changeId, "my_file.txt", content -> content.concat("Line I\nLine II\n"));
    String lastCommitId = gApi.changes().id(changeId).get().currentRevision;
    // When parentNum is 0, the diff is performed against the default base. In this case, the
    // auto-merge commit.
    Map<String, FileInfo> changedFiles = gApi.projects().name(project.get()).commit(lastCommitId).files(0);
    assertThat(changedFiles.keySet()).containsExactly("/COMMIT_MSG", "/MERGE_LIST", // file bar is coming from parent two
    "bar", "my_file.txt");
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) FileInfo(com.google.gerrit.extensions.common.FileInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 24 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class RestApiServletIT method xGerritUpdatedRefNotSetWhenUpdatedRefNotEnabled.

@Test
public void xGerritUpdatedRefNotSetWhenUpdatedRefNotEnabled() throws Exception {
    Result change = createChange();
    String origin = adminRestSession.url();
    RestResponse response = adminRestSession.putWithHeaders("/changes/" + change.getChangeId() + "/topic", /* content= */
    "A", new BasicHeader(ORIGIN, origin), new BasicHeader(X_GERRIT_UPDATED_REF_ENABLED, "false"));
    response.assertOK();
    assertThat(gApi.changes().id(change.getChangeId()).topic()).isEqualTo("A");
    // Meta ref updated because of topic update, but updated refs are not enabled.
    assertThat(response.getHeader(X_GERRIT_UPDATED_REF)).isNull();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) BasicHeader(org.apache.http.message.BasicHeader) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 25 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class RestApiServletIT method xGerritUpdatedRefNotSetByDefault.

@Test
public void xGerritUpdatedRefNotSetByDefault() throws Exception {
    Result change = createChange();
    String origin = adminRestSession.url();
    RestResponse response = adminRestSession.putWithHeaders("/changes/" + change.getChangeId() + "/topic", /* content= */
    "A", new BasicHeader(ORIGIN, origin));
    response.assertOK();
    assertThat(gApi.changes().id(change.getChangeId()).topic()).isEqualTo("A");
    // Meta ref updated because of topic update, but updated refs are not set by default.
    assertThat(response.getHeader(X_GERRIT_UPDATED_REF)).isNull();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) BasicHeader(org.apache.http.message.BasicHeader) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

Result (com.google.gerrit.acceptance.PushOneCommit.Result)75 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)59 Test (org.junit.Test)59 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)28 RestResponse (com.google.gerrit.acceptance.RestResponse)17 ObjectId (org.eclipse.jgit.lib.ObjectId)11 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)9 DraftInput (com.google.gerrit.extensions.api.changes.DraftInput)8 DiffInfo (com.google.gerrit.extensions.common.DiffInfo)7 BasicHeader (org.apache.http.message.BasicHeader)7 Request (org.apache.http.client.fluent.Request)6 FileInfo (com.google.gerrit.extensions.common.FileInfo)5 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)4 TagInput (com.google.gerrit.extensions.api.projects.TagInput)4 Project (com.google.gerrit.entities.Project)3 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)3 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)3 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 Before (org.junit.Before)3