-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Describe the main idea in readme or contribution guide (#545)
* Add standard test * Fix test
- Loading branch information
Showing
13 changed files
with
375 additions
and
219 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
55 changes: 55 additions & 0 deletions
55
.../io/github/mfvanek/pg/spring/postgres/kt/custom/ds/DatabaseStructureStaticAnalysisTest.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,55 @@ | ||
/* | ||
* Copyright (c) 2019-2024. Ivan Vakhrushev and others. | ||
* https://github.com/mfvanek/pg-index-health | ||
* | ||
* This file is a part of "pg-index-health" - a Java library for | ||
* analyzing and maintaining indexes health in PostgreSQL databases. | ||
* | ||
* Licensed under the Apache License 2.0 | ||
*/ | ||
|
||
package io.github.mfvanek.pg.spring.postgres.kt.custom.ds | ||
|
||
import io.github.mfvanek.pg.core.checks.common.DatabaseCheckOnHost | ||
import io.github.mfvanek.pg.core.checks.common.Diagnostic | ||
import io.github.mfvanek.pg.model.context.PgContext | ||
import io.github.mfvanek.pg.model.dbobject.DbObject | ||
import io.github.mfvanek.pg.model.predicates.SkipLiquibaseTablesPredicate | ||
import io.github.mfvanek.pg.model.table.Table | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.context.ActiveProfiles | ||
|
||
@SpringBootTest | ||
@ActiveProfiles("test") | ||
internal class DatabaseStructureStaticAnalysisTest { | ||
|
||
@Autowired | ||
private lateinit var checks: List<DatabaseCheckOnHost<out DbObject?>> | ||
|
||
@Test | ||
fun checksShouldWork() { | ||
assertThat(checks) | ||
.hasSameSizeAs(Diagnostic.entries.toTypedArray()) | ||
|
||
checks | ||
.filter { it.isStatic } | ||
.forEach { check -> | ||
val ctx = PgContext.of("custom_ds_schema") | ||
// Due to the use of spring.liquibase.default-schema, all names are resolved without a schema | ||
val listAssert = assertThat(check.check(ctx, SkipLiquibaseTablesPredicate.ofPublic())) | ||
.`as`(check.diagnostic.name) | ||
|
||
when (check.diagnostic) { | ||
Diagnostic.TABLES_NOT_LINKED_TO_OTHERS -> | ||
listAssert | ||
.hasSize(1) | ||
.containsExactly(Table.of("warehouse")) | ||
|
||
else -> listAssert.isEmpty() | ||
} | ||
} | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
...est/kotlin/io/github/mfvanek/pg/spring/postgres/kt/DatabaseStructureStaticAnalysisTest.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,42 @@ | ||
/* | ||
* Copyright (c) 2019-2024. Ivan Vakhrushev and others. | ||
* https://github.com/mfvanek/pg-index-health | ||
* | ||
* This file is a part of "pg-index-health" - a Java library for | ||
* analyzing and maintaining indexes health in PostgreSQL databases. | ||
* | ||
* Licensed under the Apache License 2.0 | ||
*/ | ||
|
||
package io.github.mfvanek.pg.spring.postgres.kt | ||
|
||
import io.github.mfvanek.pg.core.checks.common.DatabaseCheckOnHost | ||
import io.github.mfvanek.pg.core.checks.common.Diagnostic | ||
import io.github.mfvanek.pg.model.dbobject.DbObject | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.context.ActiveProfiles | ||
|
||
@SpringBootTest | ||
@ActiveProfiles("test") | ||
internal class DatabaseStructureStaticAnalysisTest { | ||
|
||
@Autowired | ||
private lateinit var checks: List<DatabaseCheckOnHost<out DbObject?>> | ||
|
||
@Test | ||
fun checksShouldWork() { | ||
assertThat(checks) | ||
.hasSameSizeAs(Diagnostic.entries.toTypedArray()) | ||
|
||
checks | ||
.filter { it.isStatic } | ||
.forEach { | ||
assertThat(it.check()) | ||
.`as`(it.diagnostic.name) | ||
.isEmpty() | ||
} | ||
} | ||
} |
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
Oops, something went wrong.