Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Dumas committed May 29, 2024
1 parent 4824866 commit 61e18aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class S3StorageClientSuite extends NexusSuite with LocalStackS3StorageClient.Fix
private val anotherContent = "Another content"
private val anotherContentLength = anotherContent.length.toLong

private val defaultS3ContentType = ContentTypes.`application/octet-stream`
private val contentType = ContentTypes.`application/json`
private val expectedContentType = ContentTypes.`text/plain(UTF-8)`
private val contentType = ContentTypes.`application/json`

override def munitFixtures: Seq[AnyFixture[_]] = List(localStackS3Client)

Expand All @@ -34,7 +34,7 @@ class S3StorageClientSuite extends NexusSuite with LocalStackS3StorageClient.Fix
head <- s3StorageClient.headObject(bucket, newKey)
} yield {
assertEquals(head.fileSize, contentLength)
assertEquals(head.contentType, Some(defaultS3ContentType))
assertEquals(head.contentType, Some(expectedContentType))
}
}
}
Expand Down Expand Up @@ -66,7 +66,7 @@ class S3StorageClientSuite extends NexusSuite with LocalStackS3StorageClient.Fix
} yield {
val clue = "The file should not have been overwritten"
assertEquals(head.fileSize, anotherContentLength, clue)
assertEquals(head.contentType, Some(defaultS3ContentType), clue)
assertEquals(head.contentType, Some(expectedContentType), clue)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ch.epfl.bluebrain.nexus.ship

import akka.http.scaladsl.model.{ContentType, MediaTypes}
import akka.http.scaladsl.model.{ContentType, ContentTypes, MediaTypes}
import cats.effect.IO
import ch.epfl.bluebrain.nexus.delta.kernel.Hex
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UrlUtils
Expand All @@ -9,7 +9,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.Digest.Computed
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.FileRejection.FileNotFound
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.{FileAttributes, FileState}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.DigestAlgorithm
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.LocalStackS3StorageClient
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.{LocalStackS3StorageClient, PutObjectRequest}
import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.nxv
import ch.epfl.bluebrain.nexus.delta.rdf.syntax.iriStringContextSyntax
Expand Down Expand Up @@ -61,7 +61,8 @@ class RunShipSuite

private def uploadFile(path: String) = {
val contentAsBuffer = StandardCharsets.UTF_8.encode(fileContent).asReadOnlyBuffer()
s3Client.uploadFile(Stream.emit(contentAsBuffer), importBucket, path, contentLength)
val put = PutObjectRequest(importBucket, path, ContentTypes.`application/octet-stream`, contentLength)
s3Client.uploadFile(put, Stream.emit(contentAsBuffer))
}

private def decodedFilePath(json: Json) = root.attributes.path.string.getOption(json).map(UrlUtils.decode)
Expand Down

0 comments on commit 61e18aa

Please sign in to comment.