Last active
February 27, 2020 07:34
-
-
Save nrktkt/d0e601195f2d06e74f2675a36d68fb07 to your computer and use it in GitHub Desktop.
AWS unit tests with localstack and scalatest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(...) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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