Add configurable URL
This commit is contained in:
parent
2b14d70538
commit
d849e9c1e3
8 changed files with 46 additions and 5 deletions
2
.env
Normal file
2
.env
Normal file
|
@ -0,0 +1,2 @@
|
|||
BASE_URL=http://localhost:5275
|
||||
VERSION=0.1.0
|
2
.github/workflows/build-and-test.yml
vendored
2
.github/workflows/build-and-test.yml
vendored
|
@ -39,6 +39,8 @@ jobs:
|
|||
shell: bash
|
||||
- name: Run Integration Tests
|
||||
run: dotnet test --filter Category=Integration --no-restore --verbosity normal
|
||||
env:
|
||||
BASE_URL: http://localhost:5200
|
||||
- name: Copy Integration Test Results
|
||||
run: cp test/**/TestResults/*.Integration.Tests.trx TestResults/
|
||||
shell: bash
|
||||
|
|
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
|
@ -1,3 +1,8 @@
|
|||
{
|
||||
"dotnet.defaultSolution": "GitHubActionsDemo.sln"
|
||||
"dotnet.defaultSolution": "GitHubActionsDemo.sln",
|
||||
"csharp.unitTestDebuggingOptions": {
|
||||
"env": {
|
||||
"BASE_URL": "http://localhost:5275",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
# Setup a CI/CD Pipeline Using GitHub Actions
|
||||
The code from my YouTube video on "Setup a CI/CD Pipeline Using GitHub Actions"
|
||||
|
||||
The purpose of this project is to show how you can use GitHub actions for CI/CD pipelines.
|
||||
|
||||
This project includes
|
|
@ -24,7 +24,7 @@ services:
|
|||
depends_on:
|
||||
- db
|
||||
ports:
|
||||
- '5275:5275'
|
||||
- '5200:5275'
|
||||
environment:
|
||||
- ASPNETCORE_URLS=http://*:5275
|
||||
- API_DbSettings__ConnectionString=Server=db;Database=library;Uid=dbuser;Pwd=libraryDbPassword;
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||
<PackageReference Include="Shouldly" Version="4.2.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="Xunit.DependencyInjection" Version="8.7.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
using GitHubActionsDemo.Api.Sdk.Authors;
|
||||
using GitHubActionsDemo.Api.Sdk.Books;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Refit;
|
||||
using Shouldly;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace GitHubActionsDemo.Api.Integration.Tests;
|
||||
|
||||
[Trait("Category", "Integration")]
|
||||
public class IntegrationTests
|
||||
{
|
||||
private const string BaseUri = "http://localhost:5275";
|
||||
private readonly IAuthorApi _authorApi = RestService.For<IAuthorApi>(BaseUri);
|
||||
private readonly IBookApi _bookApi = RestService.For<IBookApi>(BaseUri);
|
||||
public readonly IConfiguration _config;
|
||||
private readonly IAuthorApi _authorApi;
|
||||
private readonly IBookApi _bookApi;
|
||||
|
||||
public IntegrationTests(IConfiguration config)
|
||||
{
|
||||
_config = config ?? throw new ArgumentNullException(nameof(config));
|
||||
var baseUrl = _config.GetValue<string>("BASE_URL");
|
||||
_authorApi = RestService.For<IAuthorApi>(baseUrl);
|
||||
_bookApi = RestService.For<IBookApi>(baseUrl);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Given_valid_author_should_create_author()
|
||||
|
|
16
test/GitHubActionsDemo.Api.Integration.Tests/Startup.cs
Normal file
16
test/GitHubActionsDemo.Api.Integration.Tests/Startup.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace GitHubActionsDemo.Api.Integration.Tests;
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public void ConfigureHost(IHostBuilder hostBuilder)
|
||||
{
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.Build();
|
||||
|
||||
hostBuilder.ConfigureHostConfiguration(builder => builder.AddConfiguration(config));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue