mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-25 08:45:04 +00:00
parent
870bfd9cf0
commit
62bd9844dd
Binary file not shown.
@ -9,7 +9,7 @@ package docspell.addons
|
||||
import cats.effect._
|
||||
import cats.syntax.option._
|
||||
|
||||
import docspell.common.UrlReader
|
||||
import docspell.common._
|
||||
import docspell.logging.TestLoggingConfig
|
||||
|
||||
import munit._
|
||||
@ -42,10 +42,20 @@ class AddonArchiveTest extends CatsEffectSuite with TestLoggingConfig with Fixtu
|
||||
} yield ()
|
||||
}
|
||||
|
||||
tempDir.test("read archive from zip with yaml only") { dir =>
|
||||
for {
|
||||
aa <- AddonArchive.read[IO](singleFileAddonUrl, UrlReader.defaultReader[IO], None)
|
||||
_ = assertEquals(aa.version, "0.7.0")
|
||||
path <- aa.extractTo(UrlReader.defaultReader[IO], dir)
|
||||
read <- AddonArchive.read[IO](aa.url, UrlReader.defaultReader[IO], path.some)
|
||||
_ = assertEquals(aa, read)
|
||||
} yield ()
|
||||
}
|
||||
|
||||
tempDir.test("Read generated addon from path") { dir =>
|
||||
AddonGenerator.successAddon("mini-addon").use { addon =>
|
||||
for {
|
||||
archive <- IO(AddonArchive(addon.url, "", ""))
|
||||
archive <- IO(AddonArchive(addon.url, "test-addon", "0.1.0"))
|
||||
path <- archive.extractTo[IO](UrlReader.defaultReader[IO], dir)
|
||||
|
||||
read <- AddonArchive.read[IO](addon.url, UrlReader.defaultReader[IO], path.some)
|
||||
|
@ -31,6 +31,9 @@ trait Fixtures extends TestLoggingConfig { self: CatsEffectSuite =>
|
||||
val miniAddonUrl =
|
||||
LenientUri.fromJava(getClass.getResource("/minimal-addon.zip"))
|
||||
|
||||
val singleFileAddonUrl =
|
||||
LenientUri.fromJava(getClass.getResource("/docspell-addon-single-file.zip"))
|
||||
|
||||
val dummyAddonMeta =
|
||||
AddonMeta(
|
||||
meta =
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
package docspell.common.util
|
||||
|
||||
import cats.data.OptionT
|
||||
import cats.effect._
|
||||
import cats.syntax.all._
|
||||
import cats.{Applicative, Monad}
|
||||
@ -26,10 +27,10 @@ object Directory {
|
||||
(dir :: dirs.toList).traverse_(Files[F].createDirectories(_))
|
||||
|
||||
def nonEmpty[F[_]: Files: Sync](dir: Path): F[Boolean] =
|
||||
List(
|
||||
Files[F].isDirectory(dir),
|
||||
Files[F].list(dir).take(1).compile.last.map(_.isDefined)
|
||||
).sequence.map(_.forall(identity))
|
||||
OptionT
|
||||
.whenM(Files[F].isDirectory(dir))(Files[F].list(dir).take(1).compile.toList)
|
||||
.map(_.nonEmpty)
|
||||
.isDefined
|
||||
|
||||
def isEmpty[F[_]: Files: Sync](dir: Path): F[Boolean] =
|
||||
nonEmpty(dir).map(b => !b)
|
||||
|
Loading…
x
Reference in New Issue
Block a user