Skip to content

Commit

Permalink
Fix S3 test class names and remove 'file' references
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Peters committed Dec 22, 2020
1 parent 815d1a1 commit eb82f27
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A Scala integrations library for AWS using principles of pure functional program
Depends heavily on Cats, Cats Effect, and FS2.

Currently includes the following modules, with more to come:
* `pure-aws-s3`: S3 file sources and sinks
* `pure-aws-s3`: S3 object sources and sinks
* `pure-aws-s3-testing`: Test helpers to ensure you're using the S3 clients correctly
* `pure-aws-sqs`: Basic and simplified SQS access
* `pure-aws-sqs-refined`: Builds on top of `pure-aws-sqs` with `refined` integration for type-safe method parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.rewardsnetwork.pureaws.s3.S3ObjectOps
class TestS3ObjectOps[F[_]](backend: S3TestingBackend[F])(implicit F: MonadError[F, Throwable]) extends S3ObjectOps[F] {
def copy(oldBucket: String, oldKey: String, newBucket: String, newKey: String): F[Unit] = {
backend.get(oldBucket, oldKey).flatMap {
case None => F.raiseError(new Exception("File not found"))
case Some((meta, file)) => backend.put(newBucket, newKey, file, meta)
case None => F.raiseError(new Exception("Object not found"))
case Some((meta, obj)) => backend.put(newBucket, newKey, obj, meta)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.rewardsnetwork.pureaws.s3.S3Sink

import fs2.Pipe

class TestS3FileSink[F[_]: Sync](backend: S3TestingBackend[F]) extends S3Sink[F] {
class TestS3Sink[F[_]: Sync](backend: S3TestingBackend[F]) extends S3Sink[F] {
def writeText(bucket: String, key: String): Pipe[F, Byte, Unit] = { s =>
s.chunkAll.map(_.toByteBuffer.array).evalMap(backend.put(bucket, key, _))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import cats.implicits._
import com.rewardsnetwork.pureaws.s3.S3Source
import fs2.Stream

class TestS3FileSource[F[_]: Sync](backend: S3TestingBackend[F]) extends S3Source[F] {
class TestS3Source[F[_]: Sync](backend: S3TestingBackend[F]) extends S3Source[F] {
def readObject(bucket: String, key: String): Stream[F, Byte] =
Stream.eval(readObjectWithMetadata(bucket, key)).flatMap(_._2)
def readObjectWithMetadata(bucket: String, key: String)(implicit
F: Applicative[F]
): F[(Map[String, String], Stream[F, Byte])] =
backend.get(bucket, key).flatMap {
case Some((meta, payload)) => (meta -> Stream.emits(payload.toList).covary[F]).pure[F]
case None => Sync[F].raiseError(new Exception("File not found"))
case None => Sync[F].raiseError(new Exception("Object not found"))
}
}

0 comments on commit eb82f27

Please sign in to comment.