Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Fix #102 - add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Cameran committed Sep 3, 2020
1 parent fa3b325 commit 094272d
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
Empty file added git
Empty file.
22 changes: 22 additions & 0 deletions src/main/scala/ch/mibex/bitbucket/sonar/ParserTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ch.mibex.bitbucket.sonar

import ch.mibex.bitbucket.sonar.diff.GitDiffParser
import java.io.File
import scala.io.Source

object ParserTest {
def main(args: Array[String]): Unit = {
val fileToRead = new File("D:/tmp/sonar-plugin tests/september-2020/log_diff_mufggps.txt")
//println("File path: " + fileToRead.toString)
//val fileContents = Source.fromFile(fileToRead).mkString
val fileContents = Source.fromFile(fileToRead, "UTF-8").mkString
//println(fileContents)
GitDiffParser.parse(fileContents) match {
case Left(parsingFailure) =>
println("Failed to parse diff: " + parsingFailure.reason)
//case Right(gitDiffs) => gitDiffs.foreach {println}
case Right(gitDiffs) => println("Right!")
case _ => println("Neither")
}
}
}
8 changes: 8 additions & 0 deletions src/test/resources/diffs/diff-binary-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ similarity index 100%
rename from solutions/_templates/hybrid-solution/mvn/login/assets/finantix-logo.png
rename to solutions/_templates/hybrid/mvn/login/assets/finantix-logo.png
Binary files a/solutions/_templates/hybrid-solution/mvn/login/assets/finantix-logo.png and b/solutions/_templates/hybrid/mvn/login/assets/finantix-logo.png differ
diff --git a/main.zip b/main.zip
deleted file mode 100644
index 57676e4..0000000
Binary files a/main.zip and /dev/null differ
diff --git a/bitbucket/bitbucket-webhook b/bitbucket/bitbucket-webhook
new file mode 100755
index 0000000..3c461a4
Binary files /dev/null and b/bitbucket/bitbucket-webhook differ
35 changes: 35 additions & 0 deletions src/test/scala/ch/mibex/bitbucket/sonar/TestParser.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ch.mibex.bitbucket.sonar
/*
import ch.mibex.bitbucket.sonar.diff.GitDiffParser
import ch.mibex.bitbucket.sonar.diff.GitDiffParser.{NewFileMode, NewMode, OldMode, fileMode, newFileMode, newMode, oldMode}
import org.junit.runner.RunWith
import org.specs2.runner.JUnitRunner
import java.io.File
import scala.io.Source
import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import flatspec._
import matchers._
@RunWith(classOf[JUnitRunner])
class TestParser extends AnyFlatSpec with should.Matchers {
//private def readFile(path: String) =
// scala.io.Source.fromInputStream(getClass.getResourceAsStream(path)).mkString.replaceAll("\u0085", "")
"A binary file" should "parse diff example successfully" in {
val fileToRead = new File("D:/tmp/diff1.txt")
val fileContents = Source.fromFile(fileToRead, "UTF-8").mkString
GitDiffParser.parse(fileContents) match {
case Left(parsingFailure) =>
println("Failed to parse diff: " + parsingFailure.reason)
//case Right(gitDiffs) => gitDiffs.foreach {println}
case Right(gitDiffs) => println("Right!")
case _ => println("Neither")
}
}
}*/

0 comments on commit 094272d

Please sign in to comment.