Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple test for case where organisation is missing from a payload #259

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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());
});
}

}