Skip to content

Instantly share code, notes, and snippets.

@nrktkt
Last active February 27, 2020 07:34
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nrktkt/d0e601195f2d06e74f2675a36d68fb07 to your computer and use it in GitHub Desktop.
Save nrktkt/d0e601195f2d06e74f2675a36d68fb07 to your computer and use it in GitHub Desktop.
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