See gh-25451
This commit is contained in:
izeye
2021-02-27 01:20:32 +09:00
committed by Stephane Nicoll
parent c35a4cc283
commit c823f44e76
7 changed files with 17 additions and 17 deletions

View File

@@ -42,24 +42,24 @@ class InfluxDbHealthIndicatorTests {
void influxDbIsUp() {
Pong pong = mock(Pong.class);
given(pong.getVersion()).willReturn("0.9");
InfluxDB influxDB = mock(InfluxDB.class);
given(influxDB.ping()).willReturn(pong);
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDB);
InfluxDB influxDb = mock(InfluxDB.class);
given(influxDb.ping()).willReturn(pong);
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("version")).isEqualTo("0.9");
verify(influxDB).ping();
verify(influxDb).ping();
}
@Test
void influxDbIsDown() {
InfluxDB influxDB = mock(InfluxDB.class);
given(influxDB.ping()).willThrow(new InfluxDBException(new IOException("Connection failed")));
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDB);
InfluxDB influxDb = mock(InfluxDB.class);
given(influxDb.ping()).willThrow(new InfluxDBException(new IOException("Connection failed")));
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
verify(influxDB).ping();
verify(influxDb).ping();
}
}