-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-458 Initialize StatisticsFacade test
- Loading branch information
Showing
5 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...lite-backend/src/test/kotlin/org/panda_lang/reposilite/statistics/StatisticsFacadeTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.panda_lang.reposilite.statistics | ||
|
||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import org.panda_lang.reposilite.statistics.api.RecordType.REQUEST | ||
|
||
internal class StatisticsFacadeTest : StatisticsSpec() { | ||
|
||
@Test | ||
fun `should increase records after saving the bulk`() { | ||
// given: an uri to request | ||
val uri = "/x/y/z" | ||
|
||
// when: the given uri is requested twice | ||
statisticsFacade.increaseRecord(REQUEST, uri) | ||
statisticsFacade.increaseRecord(REQUEST, uri) | ||
statisticsFacade.saveRecordsBulk() | ||
|
||
// then: it should be properly stored in repository as a single record | ||
val records = statisticsFacade.findRecordsByPhrase(REQUEST, uri) | ||
assertEquals(1, records.size) | ||
assertEquals(2, records.get(0).count) | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
reposilite-backend/src/test/kotlin/org/panda_lang/reposilite/statistics/StatisticsSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.panda_lang.reposilite.statistics | ||
|
||
import net.dzikoysk.dynamiclogger.backend.InMemoryLogger | ||
import org.panda_lang.reposilite.statistics.infrastructure.InMemoryStatisticsRepository | ||
|
||
internal open class StatisticsSpec { | ||
|
||
protected val logger = InMemoryLogger() | ||
protected val statisticsFacade = StatisticsFacade(logger, InMemoryStatisticsRepository()) | ||
|
||
} |