guibranco / CrispyWaffle

🧰 🛠️ Crispy Waffle project - toolkit for .NET projects
https://guibranco.github.io/CrispyWaffle/
MIT License
24 stars 19 forks source link

[FEATURE] Add integration tests to `Redis` #543

Open guibranco opened 2 months ago

guibranco commented 2 months ago

Description

We need to add integration tests for Redis to ensure that our application interacts correctly with a real Redis instance. This will involve creating a new integration test project and setting up a Redis instance using Docker Compose and AppVeyor.

Steps to Implement

  1. Create Integration Tests Project:

    • Add a new test project named CrispyWaffle.IntegrationTests to the solution. It already exists
    • In this project, create a directory named Cache/Redis and add a test class RedisCacheRepositoryTests to test Redis interactions.
  2. Configure Redis for Testing:

    • Use Docker Compose to set up a Redis instance for local development and integration tests. This ensures that Redis can be easily spun up and managed as part of the testing process. The docker-compose.yml already has a Redis instance.
  3. Update AppVeyor Configuration:

    • Add steps to the AppVeyor configuration file (appveyor.yml) to set up a Redis instance for CI builds.

Tech Notes

  1. Setting Up Redis with Docker Compose:

    • Create a docker-compose.yml file in the root of your project with the following content to spin up a Redis instance:

      version: '3.1'
      
      services:
      redis:
       image: redis:5.0
       container_name: redis
       ports:
         - "6379:6379"
    • This configuration uses Redis version 5.0 and maps port 6379 for communication.
  2. Configure AppVeyor:

    • Update the appveyor.yml file to include Redis setup. You can use the following configurations:

      image: Visual Studio 2019
      
      before_build:
      - ps: |
         # Download and install Redis 5.0.14
         (new-object net.webclient).DownloadFile('https://github.com/tporadowski/redis/releases/download/v5.0.14.1/Redis-x64-5.0.14.1.msi', 'Redis-x64-5.0.14.1.msi')
         msiexec /i Redis-x64-5.0.14.1.msi /quiet /norestart
         # Start Redis server
         Start-Process "C:\Program Files\Redis\redis-server.exe" -ArgumentList "C:\Program Files\Redis\redis.windows.conf" -NoNewWindow -PassThru
    • This configuration installs Redis 5.0.14 and starts the Redis server on the AppVeyor build machine.

  3. Implement Tests:

    • In CrispyWaffle.IntegrationTests, implement tests in RedisCacheRepositoryTests to interact with the Redis instance.
    • Ensure that tests check various scenarios, such as setting, getting, and deleting cache entries.

Additional Notes

Screenshots or Diagrams

No response

Additional information

start redis-server on appveyor

gitauto-ai[bot] commented 2 months ago

Hello @guibranco, you have reached your request limit of 5, your cycle will refresh on 2024-09-21 10:07:38+00:00. Consider subscribing if you want more requests. If you have any questions or concerns, please contact us at info@gitauto.ai.

gitauto-ai[bot] commented 1 month ago

Hey, I'm a bit lost here! Not sure which file I should be fixing. Could you give me a bit more to go on? Maybe add some details to the issue or drop a comment with some extra hints? Thanks!

Have feedback or need help? Feel free to email info@gitauto.ai.