Skip to content

Commit

Permalink
Merge pull request #106 from codacy/test
Browse files Browse the repository at this point in the history
test: Add test with ExampleTool
  • Loading branch information
lolgab authored Jan 30, 2020
2 parents 7fcff5a + a3979e6 commit 3da95e0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
codacy: codacy/base@2.0.0
codacy: codacy/base@2.1.1
references:
circleci_job: &circleci_job
docker:
Expand Down
7 changes: 4 additions & 3 deletions src/main/scala/codacy/plugins/DockerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ object DockerTest extends LogSupport {
}
testRunResult match {
case Left(err) =>
error(err)
System.exit(1)
throw new Exception(err)
case Right(()) =>
debug("[Success] All tests passed!")
}
}
case wrongTypeOfTest =>
error(s"Wrong test type -> $wrongTypeOfTest should be one of [${possibleTestNames.mkString(", ")}]")
throw new Exception(
s"Wrong test type -> $wrongTypeOfTest should be one of [${possibleTestNames.mkString(", ")}]"
)
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/main/scala/codacy/plugins/test/TestFilesParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ class TestFilesParser(filesDir: JFile) extends LogSupport {
} match {
case Success(result) => result
case Failure(_) =>
error(s"${file.getName}: Failing to parse Issue $value")
System.exit(2)
None
throw new Exception(s"${file.getName}: Failing to parse Issue $value")
}
case Warning(value) =>
Some(TestFileResult(value, nextLine, Result.Level.Warn))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package codacy.plugins.test

import codacy.plugins.DockerTest
import org.scalatest._

class ExampleDuplicationToolTests extends FunSuite {
test("[ExampleDuplicationTool] tests should pass") {
DockerTest.main(Array("pattern", "codacy/codacy-example-duplication-tool:latest"))
}
test("[ExampleDuplicationTool] tests with wrong test name should throw exception") {
intercept[Exception](DockerTest.main(Array("patern", "codacy/codacy-example-duplication-tool:latest")))
}
}
13 changes: 13 additions & 0 deletions src/test/scala/codacy/plugins/test/ExampleToolTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package codacy.plugins.test

import org.scalatest._
import codacy.plugins.DockerTest

class ExampleToolTests extends FunSuite {
test("tests with ExampleTool should pass") {
DockerTest.main(Array("pattern", "codacy/codacy-example-tool:latest"))
}
test("tests with wrong test name should throw exception") {
intercept[Exception](DockerTest.main(Array("patern", "codacy/codacy-example-tool:latest")))
}
}

0 comments on commit 3da95e0

Please sign in to comment.