Search in sources :

Example 1 with DeleteTagsInput

use of com.google.gerrit.extensions.api.projects.DeleteTagsInput in project gerrit by GerritCodeReview.

the class DeleteTagsIT method deleteTagsNotFoundContinue.

@Test
public void deleteTagsNotFoundContinue() throws Exception {
    // If it fails on the first tag in the input, it should still
    // continue to process the remaining tags.
    DeleteTagsInput input = new DeleteTagsInput();
    List<String> tags = Lists.newArrayList("refs/tags/does-not-exist");
    tags.addAll(TAGS);
    input.tags = tags;
    try {
        project().deleteTags(input);
        fail("Expected ResourceConflictException");
    } catch (ResourceConflictException e) {
        assertThat(e).hasMessageThat().isEqualTo(errorMessageForTags(ImmutableList.of("refs/tags/does-not-exist")));
    }
    assertTagsDeleted();
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) DeleteTagsInput(com.google.gerrit.extensions.api.projects.DeleteTagsInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with DeleteTagsInput

use of com.google.gerrit.extensions.api.projects.DeleteTagsInput in project gerrit by GerritCodeReview.

the class DeleteTagsIT method deleteTags.

@Test
public void deleteTags() throws Exception {
    HashMap<String, RevCommit> initialRevisions = initialRevisions(TAGS);
    DeleteTagsInput input = new DeleteTagsInput();
    input.tags = TAGS;
    project().deleteTags(input);
    assertTagsDeleted();
    assertRefUpdatedEvents(initialRevisions);
}
Also used : DeleteTagsInput(com.google.gerrit.extensions.api.projects.DeleteTagsInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with DeleteTagsInput

use of com.google.gerrit.extensions.api.projects.DeleteTagsInput in project gerrit by GerritCodeReview.

the class DeleteTagsIT method deleteTagsForbidden.

@Test
public void deleteTagsForbidden() throws Exception {
    DeleteTagsInput input = new DeleteTagsInput();
    input.tags = TAGS;
    setApiUser(user);
    try {
        project().deleteTags(input);
        fail("Expected ResourceConflictException");
    } catch (ResourceConflictException e) {
        assertThat(e).hasMessageThat().isEqualTo(errorMessageForTags(TAGS));
    }
    setApiUser(admin);
    assertTags(TAGS);
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) DeleteTagsInput(com.google.gerrit.extensions.api.projects.DeleteTagsInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with DeleteTagsInput

use of com.google.gerrit.extensions.api.projects.DeleteTagsInput in project gerrit by GerritCodeReview.

the class DeleteTagsIT method deleteTagsNotFound.

@Test
public void deleteTagsNotFound() throws Exception {
    DeleteTagsInput input = new DeleteTagsInput();
    List<String> tags = Lists.newArrayList(TAGS);
    tags.add("refs/tags/does-not-exist");
    input.tags = tags;
    try {
        project().deleteTags(input);
        fail("Expected ResourceConflictException");
    } catch (ResourceConflictException e) {
        assertThat(e).hasMessageThat().isEqualTo(errorMessageForTags(ImmutableList.of("refs/tags/does-not-exist")));
    }
    assertTagsDeleted();
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) DeleteTagsInput(com.google.gerrit.extensions.api.projects.DeleteTagsInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 DeleteTagsInput (com.google.gerrit.extensions.api.projects.DeleteTagsInput)4 Test (org.junit.Test)4 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1