Commit 836eddf1 authored by bow's avatar bow
Browse files

Use TestNGSuite and Matchers in Ln command test

parent 57478950
......@@ -7,10 +7,11 @@
package nl.lumc.sasc.biopet.extensions
import java.io.File
import org.testng.Assert
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
class LnUnitTest {
class LnUnitTest extends TestNGSuite with Matchers {
@Test(description = "Target and link in the same directory, relative set to true")
def testSameLevelRelative() {
......@@ -18,7 +19,7 @@ class LnUnitTest {
ln.relative = true
ln.in = new File("/dir/nested/target.txt")
ln.out = new File("/dir/nested/link.txt")
Assert.assertEquals(ln.cmd, "ln -s 'target.txt' '/dir/nested/link.txt'")
ln.cmd should === ("ln -s 'target.txt' '/dir/nested/link.txt'")
}
@Test(description = "Target is one level above link, relative set to true")
......@@ -27,7 +28,7 @@ class LnUnitTest {
ln.relative = true
ln.in = new File("/dir/target.txt")
ln.out = new File("/dir/nested/link.txt")
Assert.assertEquals(ln.cmd, "ln -s '../target.txt' '/dir/nested/link.txt'")
ln.cmd should === ("ln -s '../target.txt' '/dir/nested/link.txt'")
}
@Test(description = "Target is two levels above link, relative set to true")
......@@ -36,7 +37,7 @@ class LnUnitTest {
ln.relative = true
ln.in = new File("/target.txt")
ln.out = new File("/dir/nested/link.txt")
Assert.assertEquals(ln.cmd, "ln -s '../../target.txt' '/dir/nested/link.txt'")
ln.cmd should === ("ln -s '../../target.txt' '/dir/nested/link.txt'")
}
@Test(description = "Target is a child of a directory one level above link, relative set to true")
......@@ -45,7 +46,7 @@ class LnUnitTest {
ln.relative = true
ln.in = new File("/dir/another_nested/target.txt")
ln.out = new File("/dir/nested/link.txt")
Assert.assertEquals(ln.cmd, "ln -s '../another_nested/target.txt' '/dir/nested/link.txt'")
ln.cmd should === ("ln -s '../another_nested/target.txt' '/dir/nested/link.txt'")
}
@Test(description = "Target is one level below link, relative set to true")
......@@ -54,7 +55,7 @@ class LnUnitTest {
ln.relative = true
ln.in = new File("/dir/nested/deeper/target.txt")
ln.out = new File("/dir/nested/link.txt")
Assert.assertEquals(ln.cmd, "ln -s 'deeper/target.txt' '/dir/nested/link.txt'")
ln.cmd should === ("ln -s 'deeper/target.txt' '/dir/nested/link.txt'")
}
@Test(description = "Target is two levels below link, relative set to true")
......@@ -63,7 +64,7 @@ class LnUnitTest {
ln.relative = true
ln.in = new File("/dir/nested/even/deeper/target.txt")
ln.out = new File("/dir/nested/link.txt")
Assert.assertEquals(ln.cmd, "ln -s 'even/deeper/target.txt' '/dir/nested/link.txt'")
ln.cmd should === ("ln -s 'even/deeper/target.txt' '/dir/nested/link.txt'")
}
@Test(description = "Relative set to false")
......@@ -72,7 +73,7 @@ class LnUnitTest {
ln.relative = false
ln.in = new File("/dir/nested/target.txt")
ln.out = new File("/dir/nested/link.txt")
Assert.assertEquals(ln.cmd, "ln -s '/dir/nested/target.txt' '/dir/nested/link.txt'")
ln.cmd should === ("ln -s '/dir/nested/target.txt' '/dir/nested/link.txt'")
}
// TODO: test for case where abosolute is true and input paths are relative?
......
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