mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 13:48:15 +08:00
Reload config on change (#527)
* Reload config on change. Added test case. * added testing for adding the json with reloadOnChange = false
This commit is contained in:

committed by
Tom Pallister

parent
89f0cc786a
commit
ad8025df1b
68
test/Ocelot.AcceptanceTests/ConfigurationReloadTests.cs
Normal file
68
test/Ocelot.AcceptanceTests/ConfigurationReloadTests.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Configuration.Setter;
|
||||
using Ocelot.Middleware;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.AcceptanceTests
|
||||
{
|
||||
public class ConfigurationReloadTests : IDisposable
|
||||
{
|
||||
private FileConfiguration _initialConfig;
|
||||
private FileConfiguration _anotherConfig;
|
||||
private Steps _steps;
|
||||
|
||||
public ConfigurationReloadTests()
|
||||
{
|
||||
_steps = new Steps();
|
||||
|
||||
_initialConfig = new FileConfiguration
|
||||
{
|
||||
GlobalConfiguration = new FileGlobalConfiguration
|
||||
{
|
||||
RequestIdKey = "initialKey"
|
||||
}
|
||||
};
|
||||
|
||||
_anotherConfig = new FileConfiguration
|
||||
{
|
||||
GlobalConfiguration = new FileGlobalConfiguration
|
||||
{
|
||||
RequestIdKey = "someOtherKey"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_reload_config_on_change()
|
||||
{
|
||||
this.Given(x => _steps.GivenThereIsAConfiguration(_initialConfig))
|
||||
.And(x => _steps.GivenOcelotIsRunningReloadingConfig(true))
|
||||
.And(x => _steps.GivenThereIsAConfiguration(_anotherConfig))
|
||||
.And(x => _steps.GivenIWait(2500))
|
||||
.And(x => _steps.ThenConfigShouldBe(_anotherConfig))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_not_reload_config_on_change()
|
||||
{
|
||||
|
||||
this.Given(x => _steps.GivenThereIsAConfiguration(_initialConfig))
|
||||
.And(x => _steps.GivenOcelotIsRunningReloadingConfig(false))
|
||||
.And(x => _steps.GivenThereIsAConfiguration(_anotherConfig))
|
||||
.And(x => _steps.GivenIWait(2500))
|
||||
.And(x => _steps.ThenConfigShouldBe(_initialConfig))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_steps.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user