Commit 0db87187 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added tests for deps

parent e73db7bf
......@@ -3,6 +3,7 @@ package nl.lumc.sasc.biopet.core
import java.io.File
import java.nio.file.Files
import nl.lumc.sasc.biopet.utils.ConfigUtils
import org.broadinstitute.gatk.queue.function.QFunction
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
......@@ -26,11 +27,27 @@ class WriteDependenciesTest extends TestNGSuite with Matchers {
}
@Test
def test: Unit = {
def testDeps: Unit = {
val outputFile = File.createTempFile("deps.", ".json")
outputFile.deleteOnExit()
WriteDependencies.writeDependencies(Qfunc(file1 :: Nil, file2 :: Nil) :: Qfunc(file2 :: Nil, file3 :: Nil) :: Nil, outputFile)
println(Source.fromFile(outputFile).getLines().mkString("\n"))
val func1 = Qfunc(file1 :: Nil, file2 :: Nil)
val func2 = Qfunc(file2 :: Nil, file3 :: Nil)
WriteDependencies.writeDependencies(func1 :: func2 :: Nil, outputFile)
val deps = ConfigUtils.fileToConfigMap(outputFile)
deps("jobs") shouldBe a[Map[_, _]]
val jobs = deps("jobs").asInstanceOf[Map[String, Map[String, Any]]]
jobs.count(_._1.contains("Qfunc")) shouldBe 2
deps("files") shouldBe a[List[_]]
val files = deps("files").asInstanceOf[List[Map[String, Any]]]
val paths = files.map(x => x.get("path")).flatten
assert(paths.contains(file1.toString))
assert(paths.contains(file2.toString))
assert(paths.contains(file3.toString))
files.find(_.get("path") == Some(file1.toString)).flatMap(_.get("pipeline_input")) shouldBe Some(true)
files.find(_.get("path") == Some(file2.toString)).flatMap(_.get("pipeline_input")) shouldBe Some(false)
files.find(_.get("path") == Some(file3.toString)).flatMap(_.get("pipeline_input")) shouldBe Some(false)
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment