Test & Validate

We believe testing is the backbone of the awsplace project. Instead of just hoping things work, we check our code at multiple levels—starting from small unit tests, up to testing our CDK infrastructure, and finally running everything through our CI/CD pipelines.

Here’s a look at how we organized our tests:

Sub-sectionDescription
5.6.1 CDK Infrastructure TestingWe use Jest to generate real CloudFormation templates and make sure our infrastructure matches what we expect
5.6.2 Application TestingUnit tests for our Go code, plus integration tests for PostgreSQL and our DynamoDB/S3 setup
5.6.3 CI/CD Pipeline ValidationOur GitHub Actions and GitLab CI workflows that automatically check every deployment

Testing Philosophy

When it comes to testing, our core rule is to test the contract, not the implementation. Instead of writing mock tests for every little CDK resource, we take a more practical approach:

  1. Synthesize real templates: First, we run cdk synth to generate the actual CloudFormation templates, just like they would appear in a real environment.
  2. Check the final output: Then, we scan the generated JSON to make sure all our important resources, exports, and configurations are exactly where they should be.
  3. Verify our deployment scripts: Finally, we validate our deployment scripts by checking them against the real shell scripts used in our CI/CD pipelines.

By testing the real output, we catch actual deployment bugs that simple mocking would completely miss.