-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ryan-williams/misc
1.1.2: plugin upgrade, resource, matcher, dependency improvements
- Loading branch information
Showing
8 changed files
with
108 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
name := "test-utils" | ||
version := "1.1.1" | ||
crossScalaVersions += "2.12.1" | ||
version := "1.1.3-SNAPSHOT" | ||
|
||
addScala212 | ||
|
||
libraryDependencies ++= Seq( | ||
libraries.value('scalatest), | ||
"commons-io" % "commons-io" % "2.4" | ||
libs.value('commons_io), | ||
libs.value('scalatest) | ||
) | ||
|
||
// Don't inherit default test-deps from parent plugin. | ||
testDeps := Seq() |
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 @@ | ||
sbt.version=0.13.13 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
addSbtPlugin("org.hammerlab" % "sbt-parent" % "1.3.0") | ||
addSbtPlugin("org.hammerlab" % "sbt-parent" % "1.5.2") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
package org.hammerlab.test.resources | ||
|
||
import java.io.FileNotFoundException | ||
import java.net.URL | ||
|
||
object Url { | ||
def apply(path: String): URL = { | ||
Thread.currentThread().getContextClassLoader.getResource(path) | ||
Option(Thread.currentThread().getContextClassLoader.getResource(path)) match { | ||
case Some(url) ⇒ url | ||
case None ⇒ | ||
throw new FileNotFoundException(s"Test resource not found: $path") | ||
} | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
src/test/scala/org/hammerlab/test/resources/ResourcesTest.scala
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,37 @@ | ||
package org.hammerlab.test.resources | ||
|
||
import java.io.FileNotFoundException | ||
|
||
import org.hammerlab.test.Suite | ||
|
||
class ResourcesTest extends Suite { | ||
test("non-existent url") { | ||
intercept[FileNotFoundException] { | ||
Url("foo") | ||
} | ||
} | ||
|
||
test("non-existent file") { | ||
intercept[FileNotFoundException] { | ||
File("foo") | ||
} | ||
} | ||
|
||
test("read file") { | ||
File("a/numbers").read should ===( | ||
"""1 | ||
|2 | ||
|3 | ||
|""".stripMargin | ||
) | ||
} | ||
|
||
test("read file bytes") { | ||
File("a/numbers").readBytes should ===( | ||
"""1 | ||
|2 | ||
|3 | ||
|""".stripMargin.getBytes | ||
) | ||
} | ||
} |