AllocZero / EfficientDynamoDb

High-performance C# DynamoDb library
https://alloczero.github.io/EfficientDynamoDb/
MIT License
204 stars 19 forks source link

DynamoDb Integration tests #132

Open lezzi opened 3 years ago

lezzi commented 3 years ago

Automate local in-memory dynamodb start to simplify writing integration tests. It can also be used as an alternative to mocking the fluent API.

Something like:

await using var inMemoryContext = InMemoryDynamoDbFactory.CreateAsync();

// Use inMemoryContext as a regular context

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html

Newp commented 2 years ago

https://github.com/AllocZero/EfficientDynamoDb/issues/172

This issue will help to conduct an integration test.

I test using github action, and because github can use docker-in-docker, local dynamodb is performed on the step of github action, and in the unit test, a client-server environment very similar to the real environment such as a separate in memory context is created.

on: pull_request:

jobs: unittest: runs-on: ubuntu-latest defaults: run : working-directory: ./server

steps:
- uses: actions/checkout@v2

- name : Run Docker Images
  run: docker-compose -f ./docker-compose-unittest.yml up -d
  working-directory: ./docker

- name: Setup .NET Core
  uses: actions/setup-dotnet@v1
  with:
    dotnet-version: 3.1.301

- name: Install dependencies
  run: dotnet restore

- name: Build
  run: dotnet build --configuration Release --no-restore

- name: curl - dynamodb
  run : curl http://localhost:8000

- name: Test
  run: dotnet test`