-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fix for file filter matching (#10)
* bug fix for file filter matching * bump version to 0.2.1
- Loading branch information
1 parent
57f840f
commit 35ff678
Showing
8 changed files
with
122 additions
and
7 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
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
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
108 changes: 108 additions & 0 deletions
108
protoc-gen-kroto-plus/src/test/kotlin/FileFilterTest.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,108 @@ | ||
package com.github.marcoferrer.krotoplus.utils | ||
|
||
import com.github.marcoferrer.krotoplus.config.FileFilter | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class FileFilterTest { | ||
|
||
val testPaths = listOf( | ||
"google/protobuf", | ||
"test/dummy/a/1", | ||
"test/dummy/a/2", | ||
"test/dummy/b/1", | ||
"test/dummy/b/2", | ||
"test/dummy/c/1", | ||
"test/dummy/c/2" | ||
) | ||
|
||
@Test | ||
fun `include all paths`(){ | ||
val fileFilter = FileFilter.getDefaultInstance() | ||
val matches = testPaths.filter { fileFilter.matches(it) } | ||
assertEquals(7, matches.size) | ||
} | ||
|
||
@Test | ||
fun `Include single path`(){ | ||
val fileFilter = FileFilter.newBuilder().addIncludePath("test/dummy/a/*").build() | ||
val matches = testPaths.filter { fileFilter.matches(it) } | ||
assertEquals(2, matches.size) | ||
assertEquals("test/dummy/a/1",matches[0]) | ||
assertEquals("test/dummy/a/2",matches[1]) | ||
} | ||
|
||
@Test | ||
fun `Include multiple paths`(){ | ||
val fileFilter = FileFilter.newBuilder() | ||
.addIncludePath("test/dummy/a/*") | ||
.addIncludePath("google/*") | ||
.build() | ||
val matches = testPaths.filter { fileFilter.matches(it) } | ||
assertEquals(3, matches.size) | ||
assertEquals("google/protobuf",matches[0]) | ||
assertEquals("test/dummy/a/1",matches[1]) | ||
assertEquals("test/dummy/a/2",matches[2]) | ||
} | ||
|
||
@Test | ||
fun `Exclude single path`(){ | ||
val fileFilter = FileFilter.newBuilder() | ||
.addExcludePath("google/*") | ||
.build() | ||
|
||
val matches = testPaths.filter { fileFilter.matches(it) } | ||
assertEquals(6, matches.size) | ||
assertEquals("test/dummy/a/1",matches[0]) | ||
assertEquals("test/dummy/a/2",matches[1]) | ||
assertEquals("test/dummy/b/1",matches[2]) | ||
assertEquals("test/dummy/b/2",matches[3]) | ||
assertEquals("test/dummy/c/1",matches[4]) | ||
assertEquals("test/dummy/c/2",matches[5]) | ||
} | ||
|
||
@Test | ||
fun `Exclude multiple paths`(){ | ||
val fileFilter = FileFilter.newBuilder() | ||
.addExcludePath("google/*") | ||
.addExcludePath("test/dummy/b/*") | ||
.build() | ||
|
||
val matches = testPaths.filter { fileFilter.matches(it) } | ||
assertEquals(4, matches.size) | ||
assertEquals("test/dummy/a/1",matches[0]) | ||
assertEquals("test/dummy/a/2",matches[1]) | ||
assertEquals("test/dummy/c/1",matches[2]) | ||
assertEquals("test/dummy/c/2",matches[3]) | ||
} | ||
|
||
@Test | ||
fun `Include and exclude paths`(){ | ||
val fileFilter = FileFilter.newBuilder() | ||
.addIncludePath("test/dummy/*") | ||
.addExcludePath("test/dummy/*/1") | ||
.build() | ||
|
||
val matches = testPaths.filter { fileFilter.matches(it) } | ||
assertEquals(3, matches.size) | ||
assertEquals("test/dummy/a/2",matches[0]) | ||
assertEquals("test/dummy/b/2",matches[1]) | ||
assertEquals("test/dummy/c/2",matches[2]) | ||
} | ||
|
||
@Test | ||
fun `Include and exclude multiple paths`(){ | ||
val fileFilter = FileFilter.newBuilder() | ||
.addIncludePath("google/*") | ||
.addIncludePath("test/dummy/*/1") | ||
.addExcludePath("test/dummy/a/*") | ||
.addExcludePath("test/dummy/c/*") | ||
.build() | ||
|
||
val matches = testPaths.filter { fileFilter.matches(it) } | ||
assertEquals(2, matches.size) | ||
assertEquals("google/protobuf",matches[0]) | ||
assertEquals("test/dummy/b/1",matches[1]) | ||
} | ||
|
||
} |