From 65c1915d5324abd7724f377e62d8b85211ab2e5c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 9 May 2019 08:48:46 +0100 Subject: [PATCH] [s3metadataenricher] enrich with metadata when remote doesn't exists returns file to upload --- .../s3thorp/S3MetaDataEnricherSuite.scala | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/test/scala/net/kemitix/s3thorp/S3MetaDataEnricherSuite.scala b/src/test/scala/net/kemitix/s3thorp/S3MetaDataEnricherSuite.scala index a614ef4..8bce7a1 100644 --- a/src/test/scala/net/kemitix/s3thorp/S3MetaDataEnricherSuite.scala +++ b/src/test/scala/net/kemitix/s3thorp/S3MetaDataEnricherSuite.scala @@ -40,20 +40,29 @@ class S3MetaDataEnricherSuite extends FunSpec { } describe("enrich with metadata") { + val local = "localFile" + val localFile = new File(sourcePath + local) describe("when remote exists") { val hash = "hash" val lastModified = Instant.now() new S3MetaDataEnricher { override def objectHead(bucket: String, key: String) = IO(Some((hash, lastModified))) it("returns metadata") { - val local = "localFile" - val localFile = new File(sourcePath + local) val expectedMetadata = S3MetaData(localFile, s"$prefix/$local", hash, lastModified) - val result: Either[File, S3MetaData] = - enrichWithS3MetaData(config)(localFile).compile.toList.unsafeRunSync().head + val result = enrichWithS3MetaData(config)(localFile).compile.toList.unsafeRunSync().head assertResult(Right(expectedMetadata))(result) } } } + describe("when remote doesn't exist") { + new S3MetaDataEnricher { + override def objectHead(bucket: String, key: String) = IO(None) + it("returns file to upload") { + val result = enrichWithS3MetaData(config)(localFile).compile.toList.unsafeRunSync().head + assertResult(Left(localFile))(result) + } + } + } + } }