Skip to content

Commit

Permalink
Let plugin fail on error (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensofficial authored Nov 24, 2023
1 parent 14423a8 commit ad2aac9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
java-version: '17'
cache: 'gradle'
- name: Production Build
run: ./gradlew clean jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.Gson;
import de.tum.cit.ase.artemis_notification_plugin.configuration.Context;
import de.tum.cit.ase.artemis_notification_plugin.configuration.ContextFactory;
import de.tum.cit.ase.artemis_notification_plugin.exception.PostResultException;
import de.tum.cit.ase.artemis_notification_plugin.exception.TestParsingException;
import de.tum.cit.ase.artemis_notification_plugin.model.Commit;
import de.tum.cit.ase.artemis_notification_plugin.model.TestResults;
Expand Down Expand Up @@ -91,6 +92,7 @@ public void postResult(TestResults results, Context context) {
}
catch (HttpException | IOException e) {
LOGGER.error(e.getMessage(), e);
throw new PostResultException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.tum.cit.ase.artemis_notification_plugin.exception;

public class PostResultException extends RuntimeException {

public PostResultException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package de.tum.cit.ase.artemis_notification_plugin.model;

import de.tum.cit.ase.artemis_notification_plugin.CLIPlugin;
import de.tum.cit.ase.artemis_notification_plugin.configuration.Context;
import de.tum.cit.ase.artemis_notification_plugin.exception.PostResultException;
import org.junit.jupiter.api.Test;

import javax.xml.bind.JAXBContext;
Expand Down Expand Up @@ -62,6 +65,12 @@ void testFlattenNestedSuiteWithFailures() throws Exception {
assertEquals(1, flattened.getErrors());
}

@Test
void testPostResultFailure() {
CLIPlugin cliPlugin = new CLIPlugin();
assertThrows(PostResultException.class, () -> cliPlugin.postResult(new TestResults(), new Context(null, null, null, null, null, null, null, null, null, null, null, "http://invalid", "secret")));
}

private Testsuite loadTestSuite(final Path reportXml) throws JAXBException {
Path resourcePath = new File("testsuite_examples").toPath().resolve(reportXml);
URL resource = getClass().getClassLoader().getResource(resourcePath.toString());
Expand Down

0 comments on commit ad2aac9

Please sign in to comment.