mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 00:28:14 +08:00
Improving logging and request id (#189)
* hacking around to work out why logging and request id isnt working * pass request id into logger so it can be structured, removed a bunch of debug logging we dont need because diagnostic trace gets it * changed config dependency * always have tracing available * made it so we dont need to pass config into services.AddOcelot anymore with .net core 2.0 * add test * lots of changes relating to logging and request ids, also updated documentation * fixed failing test i missed
This commit is contained in:
@ -25,7 +25,7 @@ namespace Ocelot.UnitTests.Infrastructure
|
||||
//TODO - Additional tests -> HttpContent null. This should never happen
|
||||
|
||||
[Fact]
|
||||
public void Get_returns_correct_key_from_http_context()
|
||||
public void get_returns_correct_key_from_http_context()
|
||||
{
|
||||
|
||||
this.Given(x => x.GivenAHttpContextContaining("key", "string"))
|
||||
@ -35,7 +35,7 @@ namespace Ocelot.UnitTests.Infrastructure
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_returns_error_response_if_the_key_is_not_found() //Therefore does not return null
|
||||
public void get_returns_error_response_if_the_key_is_not_found() //Therefore does not return null
|
||||
{
|
||||
this.Given(x => x.GivenAHttpContextContaining("key", "string"))
|
||||
.When(x => x.GetIsCalledWithKey<string>("keyDoesNotExist"))
|
||||
@ -43,6 +43,21 @@ namespace Ocelot.UnitTests.Infrastructure
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_update()
|
||||
{
|
||||
this.Given(x => x.GivenAHttpContextContaining("key", "string"))
|
||||
.And(x => x.UpdateIsCalledWith<string>("key", "new string"))
|
||||
.When(x => x.GetIsCalledWithKey<string>("key"))
|
||||
.Then(x => x.ThenTheResultIsAnOkResponse<string>("new string"))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void UpdateIsCalledWith<T>(string key, string value)
|
||||
{
|
||||
_httpDataRepository.Update(key, value);
|
||||
}
|
||||
|
||||
private void GivenAHttpContextContaining(string key, object o)
|
||||
{
|
||||
_httpContext.Items.Add(key, o);
|
||||
|
Reference in New Issue
Block a user