[config] Accept ‘parallel’ in config files (#230)

This commit is contained in:
Paul Campbell 2019-10-08 13:58:40 +01:00 committed by GitHub
parent aee0c50733
commit 1ef912ceb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 7 deletions

View file

@ -25,13 +25,14 @@ trait ParseConfigLines {
value: String
): List[ConfigOption] =
key.toLowerCase match {
case "source" => List(Source(Paths.get(value)))
case "bucket" => List(Bucket(value))
case "prefix" => List(Prefix(value))
case "include" => List(Include(value))
case "exclude" => List(Exclude(value))
case "debug" => if (truthy(value)) List(Debug()) else List.empty
case _ => List.empty
case "parallel" => value.toIntOption.map(Parallel).toList
case "source" => List(Source(Paths.get(value)))
case "bucket" => List(Bucket(value))
case "prefix" => List(Prefix(value))
case "include" => List(Include(value))
case "exclude" => List(Exclude(value))
case "debug" => if (truthy(value)) List(Debug()) else List.empty
case _ => List.empty
}
private def truthy(value: String): Boolean =

View file

@ -50,6 +50,24 @@ class ParseConfigLinesTest extends FunSpec {
assertResult(expected)(result)
}
}
describe("parallel") {
describe("when valid") {
it("should parse") {
val expected =
Right(ConfigOptions(List(ConfigOption.Parallel(3))))
val result = invoke(List("parallel = 3"))
assertResult(expected)(result)
}
}
describe("when invalid") {
it("should ignore") {
val expected =
Right(ConfigOptions(List.empty))
val result = invoke(List("parallel = invalid"))
assertResult(expected)(result)
}
}
}
describe("debug - true") {
it("should parse") {
val expected = Right(ConfigOptions(List(ConfigOption.Debug())))