Skip to content

[FEATURE] Add integration tests to Redis #543

@guibranco

Description

@guibranco

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

  • Verify that Redis is running correctly in both local development and CI environments before writing extensive tests.
  • Ensure that the docker-compose.yml file and appveyor.yml configurations are well-documented and maintained.

Screenshots or Diagrams

No response

Additional information

start redis-server on appveyor

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net codeRediscachecommunicationsenhancementNew feature or requestgitautoGitAuto label to trigger the app in a issue.good first issueGood for newcomershacktoberfestParticipation in the Hacktoberfest eventhelp wantedExtra attention is neededtestsTests⚙️ CI/CDContinuous Integration/Continuous Deployment processes🎲 databaseDatabase-related operations📝 documentationTasks related to writing or updating documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions