Skip to content

Commit

Permalink
Merge pull request #259 from holly-cummins/holly-skeleton-push-projec…
Browse files Browse the repository at this point in the history
…ts-test

Simple test for case where organisation is missing from a payload
  • Loading branch information
gsmet committed Aug 24, 2022
2 parents 3b8e91d + e445fdf commit 9cfdcf5
Show file tree
Hide file tree
Showing 2 changed files with 567 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/test/java/io/quarkus/bot/it/PushToProjectsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.quarkus.bot.it;

import io.quarkiverse.githubapp.testing.GitHubAppTest;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import org.kohsuke.github.GHEvent;

import java.io.IOException;

import static io.quarkiverse.githubapp.testing.GitHubAppTesting.given;
import static org.mockito.Mockito.verifyNoMoreInteractions;

@QuarkusTest
@GitHubAppTest
public class PushToProjectsTest {

/**
* This is a small little test which ensures that if a payload does not have an organisation, PushToProjects does not crash.
*/
@Test
void pullRequestLabeledWithNullOrganization() throws IOException {

given()
.github(mocks -> mocks.configFileFromString(
"quarkus-github-bot.yml",
"""
features: [ PUSH_TO_PROJECTS ]
project:
rules:
- labels: [area/hibernate-validator]
project: 1
issues: true
pullRequests: false
status: Todo"""))
.when().payloadFromClasspath("/pullrequest-labeled-no-organization.json")
.event(GHEvent.PULL_REQUEST)
.then().github(mocks -> {
// Without an organization, nothing should happen except a not-crash
verifyNoMoreInteractions(mocks.ghObjects());
});
}

}

0 comments on commit 9cfdcf5

Please sign in to comment.