-
-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
636e30a
commit 550f1d5
Showing
1 changed file
with
29 additions
and
33 deletions.
There are no files selected for viewing
62 changes: 29 additions & 33 deletions
62
detekt-api/src/test/kotlin/io/gitlab/arturbosch/detekt/api/internal/PathFiltersSpec.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 |
---|---|---|
@@ -1,46 +1,42 @@ | ||
package io.gitlab.arturbosch.detekt.api.internal | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Nested | ||
import org.junit.jupiter.api.Test | ||
import kotlin.io.path.Path | ||
|
||
class PathFiltersSpec { | ||
|
||
@Nested | ||
inner class `parsing with different nullability combinations of path filters` { | ||
@Test | ||
fun `returns an empty path filter when includes are empty and excludes are empty`() { | ||
val pathFilter = PathFilters.of(emptyList(), emptyList()) | ||
assertThat(pathFilter).isNull() | ||
} | ||
@Test | ||
fun `returns an empty path filter when includes are empty and excludes are empty`() { | ||
val pathFilter = PathFilters.of(emptyList(), emptyList()) | ||
assertThat(pathFilter).isNull() | ||
} | ||
|
||
@Test | ||
fun `parses includes correctly`() { | ||
val pathFilter = PathFilters.of(listOf("**/one/**", "**/two/**"), emptyList()) | ||
assertThat(pathFilter).isNotNull | ||
assertThat(pathFilter?.isIgnored(Path("/one/path"))).isFalse | ||
assertThat(pathFilter?.isIgnored(Path("/two/path"))).isFalse | ||
assertThat(pathFilter?.isIgnored(Path("/three/path"))).isTrue | ||
} | ||
@Test | ||
fun `parses includes correctly`() { | ||
val pathFilter = PathFilters.of(listOf("**/one/**", "**/two/**"), emptyList()) | ||
assertThat(pathFilter).isNotNull | ||
assertThat(pathFilter?.isIgnored(Path("/one/path"))).isFalse | ||
assertThat(pathFilter?.isIgnored(Path("/two/path"))).isFalse | ||
assertThat(pathFilter?.isIgnored(Path("/three/path"))).isTrue | ||
} | ||
|
||
@Test | ||
fun `parses excludes correctly`() { | ||
val pathFilter = PathFilters.of(emptyList(), listOf("**/one/**", "**/two/**")) | ||
assertThat(pathFilter).isNotNull | ||
assertThat(pathFilter?.isIgnored(Path("/one/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/two/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/three/path"))).isFalse | ||
} | ||
@Test | ||
fun `parses excludes correctly`() { | ||
val pathFilter = PathFilters.of(emptyList(), listOf("**/one/**", "**/two/**")) | ||
assertThat(pathFilter).isNotNull | ||
assertThat(pathFilter?.isIgnored(Path("/one/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/two/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/three/path"))).isFalse | ||
} | ||
|
||
@Test | ||
fun `parses both includes and excludes correctly`() { | ||
val pathFilter = PathFilters.of(listOf("**/one/**"), listOf("**/two/**")) | ||
assertThat(pathFilter).isNotNull | ||
assertThat(pathFilter?.isIgnored(Path("/one/path"))).isFalse | ||
assertThat(pathFilter?.isIgnored(Path("/two/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/three/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/one/two/three/path"))).isTrue | ||
} | ||
@Test | ||
fun `parses both includes and excludes correctly`() { | ||
val pathFilter = PathFilters.of(listOf("**/one/**"), listOf("**/two/**")) | ||
assertThat(pathFilter).isNotNull | ||
assertThat(pathFilter?.isIgnored(Path("/one/path"))).isFalse | ||
assertThat(pathFilter?.isIgnored(Path("/two/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/three/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/one/two/three/path"))).isTrue | ||
} | ||
} |