Added unit tests for Defaults.selectedFilter

This commit is contained in:
Matthew Farwell 2015-04-14 06:31:27 +02:00
parent a9e06109a3
commit 0e56878534
1 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,45 @@
package sbt
import java.io._
import org.specs2.mutable.Specification
object DefaultsTest extends Specification {
"`selectedFilter`" should {
def assertFiltered(filter: List[String], expected: Map[String, Boolean]) = {
val actual = expected.map(t => (t._1, Defaults.selectedFilter(filter).exists(fn => fn(t._1))))
actual must be equalTo (expected)
}
"return all tests for an empty list" in {
assertFiltered(List(), Map("Test1" -> true, "Test2" -> true))
}
"work correctly with exact matches" in {
assertFiltered(List("Test1", "foo"), Map("Test1" -> true, "Test2" -> false, "Foo" -> false))
}
"work correctly with glob" in {
assertFiltered(List("Test*"), Map("Test1" -> true, "Test2" -> true, "Foo" -> false))
}
"work correctly with excludes" in {
assertFiltered(List("Test*", "-Test2"), Map("Test1" -> true, "Test2" -> false, "Foo" -> false))
}
"work correctly without includes" in {
assertFiltered(List("-Test2"), Map("Test1" -> true, "Test2" -> false, "Foo" -> true))
}
"work correctly with excluded globs" in {
assertFiltered(List("Test*", "-F*"), Map("Test1" -> true, "Test2" -> true, "Foo" -> false))
}
"cope with multiple filters" in {
assertFiltered(List("T*1", "T*2", "-F*"), Map("Test1" -> true, "Test2" -> true, "Foo" -> false))
}
}
}