Search in sources :

Example 1 with PluginPushOption

use of com.google.gerrit.server.git.receive.PluginPushOption in project gerrit by GerritCodeReview.

the class AbstractPushForReview method pluginPushOptionsHelp.

@Test
public void pluginPushOptionsHelp() throws Exception {
    PluginPushOption fooOption = new TestPluginPushOption("foo", "some description");
    PluginPushOption barOption = new TestPluginPushOption("bar", "other description");
    try (Registration registration = extensionRegistry.newRegistration().add(fooOption).add(barOption)) {
        PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, "change2", "b.txt", "content");
        push.setPushOptions(ImmutableList.of("help"));
        PushOneCommit.Result r = push.to("refs/for/master");
        r.assertErrorStatus("see help");
        r.assertMessage("-o gerrit~bar: other description\n-o gerrit~foo: some description\n");
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PluginPushOption(com.google.gerrit.server.git.receive.PluginPushOption) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with PluginPushOption

use of com.google.gerrit.server.git.receive.PluginPushOption in project gerrit by GerritCodeReview.

the class AbstractPushForReview method pushOptionsArePassedToCommitValidationListener.

@Test
public void pushOptionsArePassedToCommitValidationListener() throws Exception {
    TestValidator validator = new TestValidator();
    PluginPushOption fooOption = new TestPluginPushOption("foo", "some description");
    PluginPushOption barOption = new TestPluginPushOption("bar", "other description");
    try (Registration registration = extensionRegistry.newRegistration().add(validator).add(fooOption).add(barOption)) {
        PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, "change2", "b.txt", "content");
        push.setPushOptions(ImmutableList.of("trace=123", "gerrit~foo", "gerrit~bar=456"));
        PushOneCommit.Result r = push.to("refs/for/master");
        r.assertOkStatus();
        assertThat(validator.getReceivedEvent().pushOptions).containsExactly("trace", "123", "gerrit~foo", "", "gerrit~bar", "456");
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PluginPushOption(com.google.gerrit.server.git.receive.PluginPushOption) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)2 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)2 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)2 PluginPushOption (com.google.gerrit.server.git.receive.PluginPushOption)2 Test (org.junit.Test)2