#529 removed raft (#543)

This commit is contained in:
Tom Pallister
2018-08-12 22:12:59 +05:30
committed by GitHub
parent 4e22b3cfc4
commit cbd0af6d75
23 changed files with 6 additions and 1437 deletions

View File

@ -8,14 +8,11 @@ using Ocelot.Responses;
using TestStack.BDDfy;
using Xunit;
using Shouldly;
using Ocelot.Raft;
using Rafty.Concensus;
using Ocelot.Configuration;
namespace Ocelot.UnitTests.Controllers
{
using Ocelot.Configuration.Repository;
using Rafty.Concensus.Node;
public class FileConfigurationControllerTests
{
@ -25,7 +22,6 @@ namespace Ocelot.UnitTests.Controllers
private IActionResult _result;
private FileConfiguration _fileConfiguration;
private readonly Mock<IServiceProvider> _provider;
private Mock<INode> _node;
public FileConfigurationControllerTests()
{
@ -70,33 +66,6 @@ namespace Ocelot.UnitTests.Controllers
.BDDfy();
}
[Fact]
public void should_post_file_configuration_using_raft_node()
{
var expected = new FileConfiguration();
this.Given(x => GivenTheFileConfiguration(expected))
.And(x => GivenARaftNodeIsRegistered())
.And(x => GivenTheNodeReturnsOK())
.And(x => GivenTheConfigSetterReturns(new OkResponse()))
.When(x => WhenIPostTheFileConfiguration())
.Then(x => x.ThenTheNodeIsCalledCorrectly())
.BDDfy();
}
[Fact]
public void should_return_error_when_cannot_set_config_using_raft_node()
{
var expected = new FileConfiguration();
this.Given(x => GivenTheFileConfiguration(expected))
.And(x => GivenARaftNodeIsRegistered())
.And(x => GivenTheNodeReturnsError())
.When(x => WhenIPostTheFileConfiguration())
.Then(x => ThenTheResponseIs<BadRequestObjectResult>())
.BDDfy();
}
[Fact]
public void should_return_error_when_cannot_set_config()
{
@ -110,33 +79,6 @@ namespace Ocelot.UnitTests.Controllers
.BDDfy();
}
private void ThenTheNodeIsCalledCorrectly()
{
_node.Verify(x => x.Accept(It.IsAny<UpdateFileConfiguration>()), Times.Once);
}
private void GivenARaftNodeIsRegistered()
{
_node = new Mock<INode>();
_provider
.Setup(x => x.GetService(typeof(INode)))
.Returns(_node.Object);
}
private void GivenTheNodeReturnsOK()
{
_node
.Setup(x => x.Accept(It.IsAny<UpdateFileConfiguration>()))
.ReturnsAsync(new Rafty.Infrastructure.OkResponse<UpdateFileConfiguration>(new UpdateFileConfiguration(new FileConfiguration())));
}
private void GivenTheNodeReturnsError()
{
_node
.Setup(x => x.Accept(It.IsAny<UpdateFileConfiguration>()))
.ReturnsAsync(new Rafty.Infrastructure.ErrorResponse<UpdateFileConfiguration>("error", new UpdateFileConfiguration(new FileConfiguration())));
}
private void GivenTheConfigSetterReturns(Response response)
{
_setter

View File

@ -75,16 +75,6 @@ namespace Ocelot.UnitTests.DependencyInjection
.BDDfy();
}
[Fact]
public void should_set_up_rafty()
{
this.Given(x => WhenISetUpOcelotServices())
.When(x => WhenISetUpRafty())
.Then(x => ThenAnExceptionIsntThrown())
.Then(x => ThenTheCorrectAdminPathIsRegitered())
.BDDfy();
}
[Fact]
public void should_set_up_administration_with_identity_server_options()
{
@ -248,18 +238,6 @@ namespace Ocelot.UnitTests.DependencyInjection
first.ShouldBe(second);
}
private void WhenISetUpRafty()
{
try
{
_ocelotBuilder.AddAdministration("/administration", "secret").AddRafty();
}
catch (Exception e)
{
_ex = e;
}
}
private void ThenAnOcelotBuilderIsReturned()
{
_ocelotBuilder.ShouldBeOfType<OcelotBuilder>();

View File

@ -57,7 +57,6 @@
<PackageReference Include="TestStack.BDDfy" Version="4.3.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Butterfly.Client.AspNetCore" Version="0.0.8" />
<PackageReference Include="Rafty" Version="0.4.4" />
</ItemGroup>
<ItemGroup>

View File

@ -1,45 +0,0 @@
using Moq;
using Ocelot.Configuration.Setter;
using Ocelot.Raft;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.Raft
{
public class OcelotFiniteStateMachineTests
{
private UpdateFileConfiguration _command;
private OcelotFiniteStateMachine _fsm;
private Mock<IFileConfigurationSetter> _setter;
public OcelotFiniteStateMachineTests()
{
_setter = new Mock<IFileConfigurationSetter>();
_fsm = new OcelotFiniteStateMachine(_setter.Object);
}
[Fact]
public void should_handle_update_file_configuration_command()
{
this.Given(x => GivenACommand(new UpdateFileConfiguration(new Ocelot.Configuration.File.FileConfiguration())))
.When(x => WhenTheCommandIsHandled())
.Then(x => ThenTheStateIsUpdated())
.BDDfy();
}
private void GivenACommand(UpdateFileConfiguration command)
{
_command = command;
}
private void WhenTheCommandIsHandled()
{
_fsm.Handle(new Rafty.Log.LogEntry(_command, _command.GetType(), 0));
}
private void ThenTheStateIsUpdated()
{
_setter.Verify(x => x.Set(_command.Configuration), Times.Once);
}
}
}