Skip to content

Commit

Permalink
#58 - LinesOfCodeIntegrationTest: three more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
iakunin committed May 3, 2020
1 parent 9210b97 commit c01b932
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public void run() {
this.githubRepoStatRepository.save(
GithubRepoStat.Factory.from(
Objects.requireNonNull(
this.codetabsClient.getLinesOfCode(githubRepo.getFullName())
this.codetabsClient
.getLinesOfCode(githubRepo.getFullName())
.getBody()
)
).setGithubRepo(githubRepo)
Expand All @@ -49,6 +50,7 @@ public void run() {
}
} finally {
log.debug("Sleeping...");
// @todo #58 configure this timeout for tests
sleep(5000);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.database.rider.core.api.dataset.DataSet;
import com.github.database.rider.core.api.dataset.ExpectedDataSet;
import com.github.tomakehurst.wiremock.client.WireMock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import dev.iakunin.codexiabot.AbstractIntegrationTest;
Expand Down Expand Up @@ -33,6 +34,16 @@ public void emptyDatabase() {
linesOfCode.run();
}

@Test
@DataSet(
value = "db-rider/github/cron/stat/lines-of-code/initial/processedRepo.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/github/cron/stat/lines-of-code/expected/processedRepo.yml")
public void processedRepo() {
linesOfCode.run();
}

@Test
@DataSet(
value = "db-rider/github/cron/stat/lines-of-code/initial/happyPath.yml",
Expand All @@ -57,6 +68,40 @@ public void happyPath() {
linesOfCode.run();
}

@Test
@DataSet(
value = "db-rider/github/cron/stat/lines-of-code/initial/tooManyRequests.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/github/cron/stat/lines-of-code/expected/tooManyRequests.yml")
public void tooManyRequests() {
WireMockServer.getInstance().stubFor(
get(WireMock.urlPathEqualTo("/loc"))
.willReturn(aResponse()
.withStatus(429)
)
);

linesOfCode.run();
}

@Test
@DataSet(
value = "db-rider/github/cron/stat/lines-of-code/initial/codetabsException.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/github/cron/stat/lines-of-code/expected/codetabsException.yml")
public void codetabsException() {
WireMockServer.getInstance().stubFor(
get(WireMock.urlPathEqualTo("/loc"))
.willReturn(aResponse()
.withStatus(500)
)
);

linesOfCode.run();
}

@AfterEach
void after() {
WireMockServer.getInstance().resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
github_repo:
-
id: 1
external_id: "150713223"
full_name: "test-project1/test-repo1"

github_repo_stat:
-
github_repo_id: 1
type: "LINES_OF_CODE"
stat: '{"itemList":null,"type":"LINES_OF_CODE"}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github_repo:
-
id: 1
external_id: "150713223"
full_name: "test-project1/test-repo1"

github_repo_stat:
-
id: 1
github_repo_id: 1
type: "LINES_OF_CODE"
stat: '{"itemList":null,"type":"LINES_OF_CODE"}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
github_repo:
-
id: 1
external_id: "150713223"
full_name: "test-project1/test-repo1"

github_repo_stat: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github_repo:
-
id: 1
uuid: "groovy: UUID.randomUUID().toString()"
external_id: "150713223"
full_name: "test-project1/test-repo1"

github_repo_stat: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
github_repo:
-
id: 1
uuid: "groovy: UUID.randomUUID().toString()"
external_id: "150713223"
full_name: "test-project1/test-repo1"

github_repo_stat:
-
id: 1
uuid: "groovy: UUID.randomUUID().toString()"
github_repo_id: 1
type: "LINES_OF_CODE"
stat: '{"itemList":null,"type":"LINES_OF_CODE"}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github_repo:
-
id: 1
uuid: "groovy: UUID.randomUUID().toString()"
external_id: "150713223"
full_name: "test-project1/test-repo1"

github_repo_stat: []

0 comments on commit c01b932

Please sign in to comment.