javatests/com/google/copybara/git/GitHubEndpointTest.java
/**
   * A test that uses feedback.
   *
   * <p>Does not verify all the fields, see {@link #testCreateStatusExhaustive()} for that.
   */
A test that uses feedback.
Does not verify all the fields, see  #testCreateStatusExhaustive() for that.
A test that uses feedback . Does not verify all the fields see #testCreateStatusExhaustive () for that .
@Test
  public void testFeedbackCreateStatus() throws Exception{
    dummyTrigger.addAll("Foo", "Bar");
    Feedback feedback =
        feedback(
            ""
                + "def test_action(ctx):\n"
                + "    ref = 'None'\n"
                + "    if len(ctx.refs) > 0:\n"
                + "      ref = ctx.refs[0]\n"
                + "    \n"
                + "    for m in ctx.origin.get_messages:\n"
                + "      status = ctx.destination.create_status(\n"
                + "        sha = ref,\n"
                + "        state = 'success',\n"
                + "        context = 'test',\n"
                + "        description = 'Observed ' + m,\n"
                + "      )\n"
                + "      ctx.console.info('Created status')\n"
                + "    return ctx.success()\n"
                + "\n");
    Iterator<String> createValues = ImmutableList.of("Observed Foo", "Observed Bar").iterator();
    gitUtil.mockApi(eq("POST"), contains("/status"),
        mockResponseAndValidateRequest("{\n"
            + "    state : 'success',\n"
            + "    target_url : 'https://github.com/google/example',\n"
            + "    description : 'Observed foo',\n"
            + "    context : 'test'\n"
            + "}",
            new MockRequestAssertion(String.format(
                "Requests were expected to cycle through the values of %s", createValues),
                r -> r.contains(createValues.next()))));
    feedback.run(workdir, ImmutableList.of("e597746de9c1704e648ddc3ffa0d2096b146d600"));
    console.assertThat().timesInLog(2, MessageType.INFO, "Created status");
    verify(gitUtil.httpTransport(), times(2)).buildRequest(eq("POST"), contains("/status"));
  }
@ Test public void testFeedbackCreateStatus ( ) throws Exception { dummyTrigger . addAll ( "Foo" , "Bar" ) ; Feedback feedback = feedback ( "" + "def test_action(ctx):\n" + "    ref = 'None'\n" + "    if len(ctx.refs) > 0:\n" + "      ref = ctx.refs[0]\n" + "    \n" + "    for m in ctx.origin.get_messages:\n" + "      status = ctx.destination.create_status(\n" + "        sha = ref,\n" + "        state = 'success',\n" + "        context = 'test',\n" + "        description = 'Observed ' + m,\n" + "      )\n" + "      ctx.console.info('Created status')\n" + "    return ctx.success()\n" + "\n" ) ; Iterator < String > createValues = ImmutableList . of ( "Observed Foo" , "Observed Bar" ) . iterator ( ) ; gitUtil . mockApi ( eq ( "POST" ) , contains ( "/status" ) , mockResponseAndValidateRequest ( "{\n" + "    state : 'success',\n" + "    target_url : 'https://github.com/google/example',\n" + "    description : 'Observed foo',\n" + "    context : 'test'\n" + "}" , new MockRequestAssertion ( String . format ( "Requests were expected to cycle through the values of %s" , createValues ) , r -> r . contains ( createValues . next ( ) ) ) ) ) ; feedback . run ( workdir , ImmutableList . of ( "e597746de9c1704e648ddc3ffa0d2096b146d600" ) ) ; console . assertThat ( ) . timesInLog ( 2 , MessageType . INFO , "Created status" ) ; verify ( gitUtil . httpTransport ( ) , times ( 2 ) ) . buildRequest ( eq ( "POST" ) , contains ( "/status" ) ) ; }
A test that uses feedback.
A test that uses feedback .