Updating docker file to not include ports. Added scripts folder and script to run docker with env vars passed via command line. Also now the build and packaging is happening in container
This commit is contained in:
parent
60efbc0f9e
commit
3262ff82b0
9 changed files with 123 additions and 7 deletions
3
tests/cartservice/.gitignore
vendored
Normal file
3
tests/cartservice/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/bin/*
|
||||
/obj/*
|
||||
/.vs/*
|
64
tests/cartservice/CartServiceTests.cs
Normal file
64
tests/cartservice/CartServiceTests.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Grpc.Core;
|
||||
using Hipstershop;
|
||||
using Xunit;
|
||||
using static Hipstershop.CartService;
|
||||
|
||||
namespace cartservice
|
||||
{
|
||||
public class E2ETests
|
||||
{
|
||||
private static string serverHostName = "172.17.0.2";
|
||||
private static int port = 7070;
|
||||
|
||||
[Fact]
|
||||
public async Task AddItem_ItemInserted()
|
||||
{
|
||||
string userId = "user1";
|
||||
|
||||
// Construct server's Uri
|
||||
string targetUri = $"{serverHostName}:{port}";
|
||||
|
||||
// Create a GRPC communication channel between the client and the server
|
||||
var channel = new Channel(targetUri, ChannelCredentials.Insecure);
|
||||
//ar interceptorObject = new ObjecT();
|
||||
//var channel.Intercept(interceptorObject);
|
||||
// Create a proxy object to work with the server
|
||||
var client = new CartServiceClient(channel);
|
||||
|
||||
var request = new AddItemRequest
|
||||
{
|
||||
UserId = userId,
|
||||
Item = new CartItem
|
||||
{
|
||||
ProductId = "1",
|
||||
Quantity = 1
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Try " + i+1);
|
||||
await client.AddItemAsync(request);
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var getCardRequest = new GetCartRequest
|
||||
{
|
||||
UserId = userId
|
||||
};
|
||||
var cart = await client.GetCartAsync(getCardRequest);
|
||||
|
||||
Assert.Equal(userId, cart.UserId);
|
||||
Assert.Single(cart.Items);
|
||||
}
|
||||
}
|
||||
}
|
30
tests/cartservice/cartservice.tests.csproj
Normal file
30
tests/cartservice/cartservice.tests.csproj
Normal file
|
@ -0,0 +1,30 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.6.0" />
|
||||
<PackageReference Include="Google.Protobuf.Tools" Version="3.6.0" />
|
||||
<PackageReference Include="Grpc" Version="1.12.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="1.12.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\cartservice\cartservice.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="xunit.runner.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
6
tests/cartservice/cartservice.tests.csproj.user
Normal file
6
tests/cartservice/cartservice.tests.csproj.user
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue