alphagov / notifications-net-client

.NET client for the GOV.UK Notify API
https://www.nuget.org/packages/GovukNotify/
MIT License
25 stars 20 forks source link

Test with docker #110

Closed leohemsted closed 4 years ago

leohemsted commented 4 years ago

Add test-with-docker and integration-test-with-docker commands to make local development easier.

nb: uses the dockerfile we originally created for concourse (that has been postponed due to difficulties publishing/releasing from a linux docker container).

Uses different commands to appveyor, which runs the commands written in appveyor.txt. I think this is fine though.

Sample output:

$ make integration-test-with-docker
scripts/generate_docker_env.sh
docker build -t govuk/notify-net-client-builder .
Sending build context to Docker daemon  4.326MB
Step 1/3 : FROM mcr.microsoft.com/dotnet/core/sdk:2.1
 ---> 7eb1ecf4a018
Step 2/3 : RUN     echo "Install base packages"     && apt-get update     && apt-get install -y --no-install-recommends     gnupg     make
 ---> Using cache
 ---> 66ed77c275ce
Step 3/3 : WORKDIR /var/project
 ---> Using cache
 ---> fb15168ff68c
Successfully built fb15168ff68c
Successfully tagged govuk/notify-net-client-builder:latest
docker run -it --rm \
        --name "leohemsted-notifications-net-client-manual-test" \
        -v "`pwd`:/var/project" \
        --env-file docker.env \
        govuk/notify-net-client-builder \
        make build-test
dotnet build -f=netcoreapp2.0
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 2.68 sec for /var/project/src/Notify.Tests/Notify.Tests.csproj.
  Restore completed in 2.68 sec for /var/project/src/Notify/Notify.csproj.
  Notify -> /var/project/src/Notify/bin/Debug/netcoreapp2.0/Notify.dll
  Notify.Tests -> /var/project/src/Notify.Tests/bin/Debug/netcoreapp2.0/Notify.Tests.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.18
dotnet test ./src/Notify.Tests/Notify.Tests.csproj --no-build -f=netcoreapp2.0 --filter TestCategory=Unit
Test run for /var/project/src/Notify.Tests/bin/Debug/netcoreapp2.0/Notify.Tests.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 16.2.0-preview-20190606-02
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Test Run Successful.
Total tests: 86
     Passed: 86
 Total time: 2.0698 Seconds
dotnet test ./src/Notify.Tests/Notify.Tests.csproj --no-build -f=netcoreapp2.0 --filter TestCategory=Integration
Test run for /var/project/src/Notify.Tests/bin/Debug/netcoreapp2.0/Notify.Tests.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 16.2.0-preview-20190606-02
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Test Run Successful.
Total tests: 56
     Passed: 56
 Total time: 13.5587 Seconds