Skip to content

Instantly share code, notes, and snippets.

@kag0 kag0/ExampleSpec.scala
Last active Feb 27, 2020

Embed
What would you like to do?
AWS unit tests with localstack and scalatest
import cloud.localstack.docker.annotation.LocalstackDockerProperties
import cloud.localstack.TestUtils
import org.scalatest.{BeforeAndAfterEach, FlatSpec}
import ...LocalstackSpec
@LocalstackDockerProperties(services = Array("s3"))
class ExampleSpec
extends FlatSpec
with BeforeAndAfterEach
with LocalStackSpec {
override def beforeEach() = localstackStart()
override def afterEach() = localstackStop()
"s3 access" should "work" in {
// access s3 API @ localhost
val s3 = TestUtils.getClientS3
s3.putObject(...)
}
}
import cloud.localstack.Localstack
import cloud.localstack.docker.annotation.LocalstackDockerAnnotationProcessor
trait LocalstackSpec {
def localstackStart() = {
val config = LocalstackSpec.processor.process(this.getClass)
Localstack.INSTANCE.startup(config)
}
def localstackStop() = Localstack.INSTANCE.stop()
}
object LocalstackSpec {
val processor = new LocalstackDockerAnnotationProcessor
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.