Skip to content

Commit

Permalink
Merge pull request #16 from DoctorLogicUS/env
Browse files Browse the repository at this point in the history
Added .env support to integration tests project
  • Loading branch information
Simon Wahlström committed Aug 18, 2020
2 parents 00dd4fa + 94d6e1c commit 8d9d607
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,6 +1,9 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific env variables
.env

# User-specific files
*.suo
*.user
Expand Down
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -54,6 +54,10 @@ dotnet test test/Tinify.Tests
dotnet restore
TINIFY_KEY=$YOUR_API_KEY dotnet test test/Tinify.Tests.Integration
```
Or add a `.env` file to the `/test/Tinify.Tests.Integration` directory in the format
```
TINIFY_KEY=<YOUR_API_KEY>
```

## License

Expand Down
3 changes: 3 additions & 0 deletions test/Tinify.Tests.Integration/Integration.cs
Expand Up @@ -47,6 +47,9 @@ public class Client_Integration
[OneTimeSetUp]
public static void Init()
{
var currDir = Directory.GetCurrentDirectory();
DotNetEnv.Env.Load();

Tinify.Key = Environment.GetEnvironmentVariable("TINIFY_KEY");
Tinify.Proxy = Environment.GetEnvironmentVariable("TINIFY_PROXY");

Expand Down
17 changes: 11 additions & 6 deletions test/Tinify.Tests.Integration/Tinify.Tests.Integration.csproj
Expand Up @@ -14,23 +14,28 @@

<ItemGroup>
<None Remove=".DS_Store" />
<None Remove="examples\voormedia.png" />
<None Remove=".env" />
<Content Include="examples\voormedia.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../src/Tinify/Tinify.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotNetEnv" Version="1.4.0" />
<PackageReference Include="RichardSzalay.MockHttp" Version="3.2.1" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
</ItemGroup>

<ItemGroup>
<Content Include="examples\voormedia.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Target Name="CopyEnv" AfterTargets="AfterBuild">
<!-- Copy user's .env file if it exists -->
<Copy Condition="Exists('.env')" SourceFiles=".env" DestinationFolder="$(OutDir)" />
</Target>

</Project>

0 comments on commit 8d9d607

Please sign in to comment.