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

remise finale #250

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,24 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew build jacocoTestReport

- name: Upload JaCoCo coverage report as a workflow artifact
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: ${{ github.workspace }}/build/reports/jacoco/test/html

- name: Jacoco Report to PR
id: jacoco
uses: madrapps/jacoco-report@v1.6.1
with:
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
title: Code Coverage
update-comment: true
- name: Get the Coverage info
run: |
echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ bin/
build/
classes
out
.DS_STORE
Binary file added LOG8371_tp1.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SPUTNIK
![sputnik](http://touk.github.io/sputnik/images/logo-color-bgtransparent-small.png)

> Static code review for your Gerrit and Stash patchsets. Runs Checkstyle, PMD, SpotBugs (formerly known as FindBugs), Scalastyle, CodeNarc, JSLint, JSHint, TSLint and Detekt for you!
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ dependencies {

test {
useJUnitPlatform()
testLogging {
events "passed"
}
}

// Jacoco + coveralls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import pl.touk.sputnik.HttpConnectorEnv;
import pl.touk.sputnik.configuration.Configuration;
import pl.touk.sputnik.configuration.ConfigurationSetup;
Expand All @@ -24,6 +26,8 @@
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.*;

class StashFacadeTest {

Expand All @@ -42,13 +46,17 @@ class StashFacadeTest {
private WireMockServer wireMockServer;
private HttpConnectorEnv httpConnectorEnv;

@Mock
private StashFacade stashFacadeMock;


@BeforeEach
void setUp() {
wireMockServer = new WireMockServer(wireMockConfig().port(FacadeConfigUtil.HTTP_PORT).httpsPort(FacadeConfigUtil.HTTPS_PORT));
wireMockServer.start();

httpConnectorEnv = new HttpConnectorEnv(wireMockServer);

MockitoAnnotations.initMocks(this);
config = new ConfigurationSetup().setUp(FacadeConfigUtil.getHttpConfig("stash"), STASH_PATCHSET_MAP);
stashFacade = new StashFacadeBuilder().build(config);
}
Expand All @@ -58,6 +66,17 @@ void tearDown() {
wireMockServer.stop();
}

@Test
public void testListFilesErrorHandling(){
when(stashFacadeMock.listFiles()).thenThrow(new StashException("Error when listing files"));
StashException thrown = assertThrows(
StashException.class,
() -> stashFacadeMock.listFiles(),
"Expected listFiles() to throw, but it didn't"
);
assertThat(thrown.getMessage()).isEqualTo("Error when listing files");
}

@Test
void shouldGetChangeInfo() throws Exception {
httpConnectorEnv.stubGet(urlEqualTo(String.format(
Expand Down