Skip to content

Commit

Permalink
(fix) Only return CI builds in duration timeline (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
craigatk authored Sep 25, 2020
1 parent 95c57c9 commit 5c32274
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ context("repository timeline", () => {

cy.readFile("cypress/fixtures/grouped-passing-tests-with-git.json").then(
(resultsBlob) => {
resultsBlob.metadata.ci = true;
resultsBlob.metadata.git.repoName = repoName;

cy.loadGroupedFixtureData(resultsBlob, "");
Expand All @@ -16,6 +17,7 @@ context("repository timeline", () => {

cy.readFile("cypress/fixtures/grouped-passing-tests-with-git.json").then(
(resultsBlob) => {
resultsBlob.metadata.ci = true;
resultsBlob.metadata.git.repoName = repoName;

cy.loadGroupedFixtureData(resultsBlob, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RepositoryTestRunDatabaseRepository(private val dslContext: DSLContext) :
it.and(GIT_METADATA.PROJECT_NAME.isNull)
else
it.and(GIT_METADATA.PROJECT_NAME.eq(projectName))
}.and((RESULTS_METADATA.CI.isNull).or(RESULTS_METADATA.CI.eq(true))))
}.and(RESULTS_METADATA.CI.eq(true)))
.orderBy(TEST_RUN.CREATED_TIMESTAMP.asc())
.fetchResultSet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,14 @@ class RepositoryTestRunDatabaseRepositoryTest : DatabaseRepositoryTestCase() {
val timeline = runBlocking { repositoryTestRunDatabaseRepository.fetchRepositoryTestRunTimeline(repoName, projectName) }
assertNotNull(timeline)

expectThat(timeline.timelineEntries).hasSize(2)
expectThat(timeline.timelineEntries).hasSize(1)

val firstEntry = timeline.timelineEntries[0]
expectThat(firstEntry) {
get { publicId }.isEqualTo(firstRunCITruePublicId.id)
get { totalTestCount }.isEqualTo(20)
get { cumulativeDuration }.isEqualTo(BigDecimal("25.000"))
}

val secondEntry = timeline.timelineEntries[1]
expectThat(secondEntry) {
get { publicId }.isEqualTo(secondRunCINullPublicId.id)
get { totalTestCount }.isEqualTo(30)
get { cumulativeDuration }.isEqualTo(BigDecimal("35.000"))
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ class RepositoryTestRunTimelineApplicationTest : ApplicationTestCase() {
val firstTestRun = createTestRun(firstRunPublicId, 20, BigDecimal("10.001"))
testRunDao.insert(firstTestRun)
testRunDBGenerator.addGitMetadata(firstTestRun, repoName, true, "main", null)
testRunDBGenerator.addResultsMetadata(firstTestRun, true)

val secondTestRun = createTestRun(secondRunPublicId, 30, BigDecimal("15.001"))
testRunDao.insert(secondTestRun)
testRunDBGenerator.addGitMetadata(secondTestRun, repoName, true, "main", null)
testRunDBGenerator.addResultsMetadata(secondTestRun, true)

val thirdTestRun = createTestRun(thirdRunPublicId, 45, BigDecimal("25.001"))
testRunDao.insert(thirdTestRun)
testRunDBGenerator.addGitMetadata(thirdTestRun, repoName, true, "main", null)
testRunDBGenerator.addResultsMetadata(thirdTestRun, true)
}.apply {
expectThat(response.status()).isEqualTo(HttpStatusCode.OK)

Expand Down Expand Up @@ -86,14 +89,17 @@ class RepositoryTestRunTimelineApplicationTest : ApplicationTestCase() {
val firstTestRun = createTestRun(firstRunPublicId, 20, BigDecimal("10.001"))
testRunDao.insert(firstTestRun)
testRunDBGenerator.addGitMetadata(firstTestRun, repoName, true, "main", projectName)
testRunDBGenerator.addResultsMetadata(firstTestRun, true)

val secondTestRun = createTestRun(secondRunPublicId, 30, BigDecimal("15.001"))
testRunDao.insert(secondTestRun)
testRunDBGenerator.addGitMetadata(secondTestRun, repoName, true, "main", projectName)
testRunDBGenerator.addResultsMetadata(secondTestRun, true)

val thirdTestRun = createTestRun(thirdRunPublicId, 45, BigDecimal("25.001"))
testRunDao.insert(thirdTestRun)
testRunDBGenerator.addGitMetadata(thirdTestRun, repoName, true, "main", projectName)
testRunDBGenerator.addResultsMetadata(thirdTestRun, true)
}.apply {
expectThat(response.status()).isEqualTo(HttpStatusCode.OK)

Expand Down

0 comments on commit 5c32274

Please sign in to comment.