1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-08-31 21:38:12 +02:00

internal/api/interface.go: make Call() accept a context as parameter.

This commit is contained in:
Henrik Hautakoski 2023-02-06 14:20:09 +01:00
parent b815bcee44
commit dbf59d1305
No known key found for this signature in database
GPG key ID: 217490840C18A5D9
10 changed files with 47 additions and 30 deletions

View file

@ -1,6 +1,7 @@
package api
import (
"context"
"net/http"
"net/http/httptest"
"testing"
@ -50,7 +51,7 @@ func TestAtomicAsset_JsonFailure(t *testing.T) {
}))
api := NewAtomicAsset(srv.URL, 120)
check, _ := api.Call()
check, _ := api.Call(context.Background())
expected := agentcheck.NewStatusMessageResponse(agentcheck.Fail, "")
assert.Equal(t, expected, check)
@ -65,7 +66,7 @@ func TestAtomicAsset_HTTP500Down(t *testing.T) {
}))
api := NewAtomicAsset(srv.URL, 120)
check, status := api.Call()
check, status := api.Call(context.Background())
assert.Equal(t, "Taking offline because 500 was received from backend", status)
@ -104,7 +105,7 @@ func TestAtomicAsset_LaggingUp(t *testing.T) {
api := NewAtomicAsset(srv.URL, 120)
api.SetTime(time.Date(2025, 10, 8, 20, 7, 27, 0, time.UTC))
check, status := api.Call()
check, status := api.Call(context.Background())
assert.Equal(t, "OK", status)
@ -143,7 +144,7 @@ func TestAtomicAsset_LaggingDown(t *testing.T) {
api := NewAtomicAsset(srv.URL, 120)
api.SetTime(time.Date(2018, 8, 5, 6, 53, 35, 0, time.UTC))
check, status := api.Call()
check, status := api.Call(context.Background())
assert.Equal(t, "Taking offline because head block is lagging 121 seconds", status)
@ -182,7 +183,7 @@ func TestAtomicAsset_InFutureUp(t *testing.T) {
api := NewAtomicAsset(srv.URL, 120)
api.SetTime(time.Date(2024, 10, 15, 1, 9, 16, 500, time.UTC))
check, status := api.Call()
check, status := api.Call(context.Background())
assert.Equal(t, "OK", status)
@ -221,7 +222,7 @@ func TestAtomicAsset_InFutureDown(t *testing.T) {
api := NewAtomicAsset(srv.URL, 120)
api.SetTime(time.Date(2002, 12, 29, 0, 45, 0o3, 500, time.UTC))
check, status := api.Call()
check, status := api.Call(context.Background())
assert.Equal(t, "Taking offline because head block is -121 seconds into the future", status)
@ -260,7 +261,7 @@ func TestAtomicAsset_RedisDown(t *testing.T) {
api := NewAtomicAsset(srv.URL, 120)
api.SetTime(time.Date(2015, 3, 11, 11, 19, 30, 500, time.UTC))
check, status := api.Call()
check, status := api.Call(context.Background())
assert.Equal(t, "Taking offline because Redis reported 'DOWN'", status)
@ -299,7 +300,7 @@ func TestAtomicAsset_PostgresDown(t *testing.T) {
api := NewAtomicAsset(srv.URL, 120)
api.SetTime(time.Date(2019, 7, 11, 18, 6, 11, 500, time.UTC))
check, status := api.Call()
check, status := api.Call(context.Background())
assert.Equal(t, "Taking offline because Postgres reported 'DOWN'", status)