public void Health_NoPropertySources_ReturnsExpected() { // this test does NOT expect to find a running config server var values = new Dictionary <string, string>() { { "spring:cloud:config:uri", "http://localhost:8887/" }, { "spring:cloud:config:name", "myName" }, { "spring:cloud:config:label", "myLabel" }, { "spring:cloud:config:health:enabled", "true" }, { "spring:cloud:config:health:timeToLive", "1" }, { "spring:cloud:config:timeout", "10" }, }; var builder = new ConfigurationBuilder(); builder.AddInMemoryCollection(values); builder.AddConfigServer(); var config = builder.Build(); var contributor = new ConfigServerHealthContributor(config); Assert.NotNull(contributor.Provider); var health = contributor.Health(); Assert.NotNull(health); Assert.Equal(HealthStatus.UNKNOWN, health.Status); Assert.True(health.Details.ContainsKey("error")); }
public void Health_NotEnabled_ReturnsExpected() { var values = new Dictionary <string, string>() { { "spring:cloud:config:uri", "http://localhost:8888/" }, { "spring:cloud:config:name", "myName" }, { "spring:cloud:config:label", "myLabel" }, { "spring:cloud:config:health:enabled", "false" }, { "spring:cloud:config:health:timeToLive", "1" }, { "spring:cloud:config:timeout", "10" }, }; var builder = new ConfigurationBuilder(); builder.AddInMemoryCollection(values); builder.AddConfigServer(); var config = builder.Build(); var contributor = new ConfigServerHealthContributor(config); Assert.NotNull(contributor.Provider); var health = contributor.Health(); Assert.NotNull(health); Assert.Equal(HealthStatus.UNKNOWN, health.Status); }