Skip to content

Commit

Permalink
add test for two exclusive databases for one service
Browse files Browse the repository at this point in the history
  • Loading branch information
jooaodanieel committed Apr 24, 2022
1 parent 4ddf960 commit 5f1539d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,18 @@ internal class DatabasePerServiceDetectorTest {
val results = underTest.getResults()
assertEquals(1, results.size)
}

@Test
fun `it correctly do not detect when service uses two databases`() {
// given
val visitable = Scenarios.oneServiceWithTwoDatabases()
visitable.forEach { it.accept(MetricCollector()) }

// when
visitable.forEach { it.accept(underTest) }

// then
val results = underTest.getResults()
assertEquals(0, results.size)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,16 @@ class Scenarios {

return listOf(service)
}

fun oneServiceWithTwoDatabases(): List<Visitable> {
val service = Service(name = "foo", systemName = Slug.from("foo system"))
val db1 = Database(name = "db 1", DataSource.MongoDb)
val db2 = Database(name = "db 2", DataSource.PostgreSql)

DatabaseUsage(service, database = db1, accessMode = DatabaseAccessMode.ReadWrite)
DatabaseUsage(service, database = db2, accessMode = DatabaseAccessMode.ReadWrite)

return listOf(service)
}
}
}

0 comments on commit 5f1539d

Please sign in to comment.