Skip to content

Commit

Permalink
Cover TreeCopyFileVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
reid-spencer committed May 11, 2024
1 parent f50746a commit 70de00e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.io.IOException
import java.nio.file.*
import java.nio.file.attribute.BasicFileAttributes

/** Unit Tests For TreeCopyFileVisitor */
/** A FIle Visitor that copies a directory hierarchy*/
case class TreeCopyFileVisitor(source: Path, target: Path, log: Logger = SysLogger())
extends SimpleFileVisitor[Path] {

Expand All @@ -39,11 +39,12 @@ case class TreeCopyFileVisitor(source: Path, target: Path, log: Logger = SysLogg
FileVisitResult.CONTINUE
}

override def visitFileFailed(
/* override def visitFileFailed(
file: Path,
exc: IOException
): FileVisitResult = {
log.error(s"Unable to copy: $file: $exc\n")
FileVisitResult.CONTINUE
}
*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.ossuminc.riddl.hugo.utils

import org.scalatest.matchers.must.Matchers
import org.scalatest.wordspec.AnyWordSpec

import java.nio.file.Path
import java.nio.file.Files

class TreeCopyFileVisitorTest extends AnyWordSpec with Matchers {

"TreeCopyFileVisitor" must {
val source = Path.of("hugo/src/test/input")
val target: Path = Files.createTempDirectory("TCFV-test")
val visitor = TreeCopyFileVisitor(source, target)

"copies input files" in {
Files.createDirectories(target.resolve("regressions")) // To make it delete something
val result = Files.walkFileTree(source, visitor)
result must be(source)
Files.isDirectory(target) must be(true)
}
}
}

0 comments on commit 70de00e

Please sign in to comment.