1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-16 04:44:55 +02:00

Cleanup test names.

This commit is contained in:
Henrik Hautakoski 2022-11-24 14:56:22 +01:00
parent d2b8e7d0dc
commit c89da02738
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
9 changed files with 50 additions and 50 deletions

View file

@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestAtomicAssetFactory(t *testing.T) {
func TestAtomicAsset_Factory(t *testing.T) {
api := AtomicAssetFactory(ApiArguments{
Url: "https://atomic.example.com",
NumBlocks: 120,
@ -24,7 +24,7 @@ func TestAtomicAssetFactory(t *testing.T) {
assert.Equal(t, expected.block_time, api.(AtomicAsset).block_time)
}
func TestAtomicAssetLogInfo(t *testing.T) {
func TestAtomicAsset_LogInfo(t *testing.T) {
api := NewAtomicAsset("https://atomic.example.com", 120)
expected := LogParams{"type", "atomicasset", "url", "https://atomic.example.com", "block_time", float64(120)}
@ -32,7 +32,7 @@ func TestAtomicAssetLogInfo(t *testing.T) {
assert.Equal(t, expected, api.LogInfo())
}
func TestAtomicAssetSetTime(t *testing.T) {
func TestAtomicAsset_SetTime(t *testing.T) {
expected := time.Date(2019, 3, 18, 20, 29, 32, 0, time.UTC)
api := NewAtomicAsset("", 60)
@ -43,7 +43,7 @@ func TestAtomicAssetSetTime(t *testing.T) {
assert.Equal(t, expected, api.GetTime())
}
func TestAtomicAssetJsonFailure(t *testing.T) {
func TestAtomicAsset_JsonFailure(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
_, err := res.Write([]byte(`!//{invalid-json}!##`))
assert.NoError(t, err)
@ -56,7 +56,7 @@ func TestAtomicAssetJsonFailure(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestAtomicAssetHTTP500Down(t *testing.T) {
func TestAtomicAsset_HTTP500Down(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.Header().Add("Content-type", "application/json; charset=utf-8")
res.WriteHeader(500)
@ -73,7 +73,7 @@ func TestAtomicAssetHTTP500Down(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestAtomicAssetLaggingUp(t *testing.T) {
func TestAtomicAsset_LaggingUp(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/health" {
payload := `{
@ -112,7 +112,7 @@ func TestAtomicAssetLaggingUp(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestAtomicAssetLaggingDown(t *testing.T) {
func TestAtomicAsset_LaggingDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/health" {
payload := `{
@ -151,7 +151,7 @@ func TestAtomicAssetLaggingDown(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestAtomicAssetInFutureUp(t *testing.T) {
func TestAtomicAsset_InFutureUp(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/health" {
payload := `{
@ -190,7 +190,7 @@ func TestAtomicAssetInFutureUp(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestAtomicAssetInFutureDown(t *testing.T) {
func TestAtomicAsset_InFutureDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/health" {
payload := `{
@ -229,7 +229,7 @@ func TestAtomicAssetInFutureDown(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestAtomicAssetRedisDown(t *testing.T) {
func TestAtomicAsset_RedisDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/health" {
payload := `{
@ -268,7 +268,7 @@ func TestAtomicAssetRedisDown(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestAtomicAssetPostgresDown(t *testing.T) {
func TestAtomicAsset_PostgresDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/health" {
payload := `{

View file

@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestDebugApiFactory(t *testing.T) {
func TestDebugApi_Factory(t *testing.T) {
api := DebugApiFactory(ApiArguments{
Url: "up",
Host: "host",

View file

@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestEosioV1Factory(t *testing.T) {
func TestEosioV1_Factory(t *testing.T) {
api := EosioV1Factory(ApiArguments{
Url: "https://api.v1.example.com",
Host: "host.example.com",
@ -25,7 +25,7 @@ func TestEosioV1Factory(t *testing.T) {
assert.Equal(t, expected.block_time, api.(EosioV1).block_time)
}
func TestEosioV1LogInfo(t *testing.T) {
func TestEosioV1_LogInfo(t *testing.T) {
api := NewEosioV1("https://api.v1.example.com", "host.example.com", 120)
expected := LogParams{"type", "eosio-v1", "url", "https://api.v1.example.com", "host", "host.example.com", "block_time", float64(120)}
@ -33,7 +33,7 @@ func TestEosioV1LogInfo(t *testing.T) {
assert.Equal(t, expected, api.LogInfo())
}
func TestEosioV1SetTime(t *testing.T) {
func TestEosioV1_SetTime(t *testing.T) {
expected := time.Date(2022, 2, 24, 13, 38, 0, 0, time.UTC)
api := NewEosioV1("", "", 60)
@ -44,7 +44,7 @@ func TestEosioV1SetTime(t *testing.T) {
assert.Equal(t, expected, api.GetTime())
}
func TestEosioV1JsonFailure(t *testing.T) {
func TestEosioV1_JsonFailure(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
_, err := res.Write([]byte(`!//{invalid-json}!##`))
assert.NoError(t, err)
@ -57,7 +57,7 @@ func TestEosioV1JsonFailure(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV1HTTP500Failed(t *testing.T) {
func TestEosioV1_HTTP500Failed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(500)
_, err := res.Write([]byte(`{}`))
@ -73,7 +73,7 @@ func TestEosioV1HTTP500Failed(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV1LaggingUp(t *testing.T) {
func TestEosioV1_LaggingUp(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v1/chain/get_info" {
info := `{
@ -97,7 +97,7 @@ func TestEosioV1LaggingUp(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV1LaggingDown(t *testing.T) {
func TestEosioV1_LaggingDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v1/chain/get_info" {
info := `{
@ -121,7 +121,7 @@ func TestEosioV1LaggingDown(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV1TimeInFutureUP(t *testing.T) {
func TestEosioV1_TimeInFutureUP(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v1/chain/get_info" {
info := `{
@ -145,7 +145,7 @@ func TestEosioV1TimeInFutureUP(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV1TimeInFutureDown(t *testing.T) {
func TestEosioV1_TimeInFutureDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v1/chain/get_info" {
info := `{

View file

@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestEosioV2Factory(t *testing.T) {
func TestEosioV2_Factory(t *testing.T) {
api := EosioV2Factory(ApiArguments{
Url: "https://api.v2.example.com",
Host: "host.example.com",
@ -24,7 +24,7 @@ func TestEosioV2Factory(t *testing.T) {
assert.Equal(t, expected.offset, api.(EosioV2).offset)
}
func TestEosioV2LogInfo(t *testing.T) {
func TestEosioV2_LogInfo(t *testing.T) {
api := NewEosioV2("https://api.v2.example.com", "host.example.com", 120)
expected := LogParams{"type", "eosio-v2", "url", "https://api.v2.example.com", "host", "host.example.com", "offset", int64(120)}
@ -32,7 +32,7 @@ func TestEosioV2LogInfo(t *testing.T) {
assert.Equal(t, expected, api.LogInfo())
}
func TestEosioV2JsonFailure(t *testing.T) {
func TestEosioV2_JsonFailure(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
_, err := res.Write([]byte(`!//{invalid-json}!##`))
assert.NoError(t, err)
@ -45,7 +45,7 @@ func TestEosioV2JsonFailure(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV2HTTP500Failed(t *testing.T) {
func TestEosioV2_HTTP500Failed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(500)
_, err := res.Write([]byte(`{}`))
@ -61,7 +61,7 @@ func TestEosioV2HTTP500Failed(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV2LaggingUp(t *testing.T) {
func TestEosioV2_LaggingUp(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" {
info := `{
@ -108,7 +108,7 @@ func TestEosioV2LaggingUp(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV2LaggingDown(t *testing.T) {
func TestEosioV2_LaggingDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" {
info := `{
@ -155,7 +155,7 @@ func TestEosioV2LaggingDown(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV2LaggingESInFutureUP(t *testing.T) {
func TestEosioV2_LaggingESInFutureUP(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" {
info := `{
@ -202,7 +202,7 @@ func TestEosioV2LaggingESInFutureUP(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV2LaggingESInFutureDown(t *testing.T) {
func TestEosioV2_LaggingESInFutureDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" {
info := `{
@ -249,7 +249,7 @@ func TestEosioV2LaggingESInFutureDown(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV2ElasticsFailed(t *testing.T) {
func TestEosioV2_ElasticsFailed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" {
info := `{
@ -296,7 +296,7 @@ func TestEosioV2ElasticsFailed(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV2NodeosRPCFailed(t *testing.T) {
func TestEosioV2_NodeosRPCFailed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" {
info := `{
@ -343,7 +343,7 @@ func TestEosioV2NodeosRPCFailed(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV2ElasticsNodeosRPCFailed(t *testing.T) {
func TestEosioV2_ElasticsNodeosRPCFailed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" {
info := `{

View file

@ -31,7 +31,7 @@ func TestLogParams(t *testing.T) {
assert.ElementsMatch(t, expected, p)
}
func TestLogParamsCombine(t *testing.T) {
func TestLogParams_Combine(t *testing.T) {
a := LogParams{"one", 1, "string1", "str1"}
b := LogParams{"two", 2, "string2", "str2"}

View file

@ -7,14 +7,14 @@ import (
"github.com/stretchr/testify/assert"
)
func TestParseWithInvalidApi(t *testing.T) {
func TestParseRequest_WithInvalidApi(t *testing.T) {
api, err := ParseRequest("invalid|http://api.example.com")
assert.Error(t, err)
assert.Equal(t, err.Error(), "invalid API 'invalid'")
assert.Nil(t, api)
}
func TestParseWithInvalidParams(t *testing.T) {
func TestParseRequest_WithInvalidParams(t *testing.T) {
api, err := ParseRequest("v1")
assert.Error(t, err)
assert.Equal(t, err.Error(), "invalid number of parameters in agent request")
@ -24,7 +24,7 @@ func TestParseWithInvalidParams(t *testing.T) {
// EosioV1
// --------------------------------
func TestParseEosioV1(t *testing.T) {
func TestParseRequest_EosioV1(t *testing.T) {
expected := api.NewEosioV1("http://api.example.com", "", 5)
api, err := ParseRequest("v1|http://api.example.com")
@ -32,7 +32,7 @@ func TestParseEosioV1(t *testing.T) {
assert.Equal(t, expected.LogInfo(), api.LogInfo())
}
func TestParseEosioV1WithBlockNumber(t *testing.T) {
func TestParseRequest_EosioV1WithBlockNumber(t *testing.T) {
expected := api.NewEosioV1("http://api.example.com", "", 1000)
api, err := ParseRequest("v1|http://api.example.com|2000")
@ -40,7 +40,7 @@ func TestParseEosioV1WithBlockNumber(t *testing.T) {
assert.Equal(t, expected.LogInfo(), api.LogInfo())
}
func TestParseEosioV1Full(t *testing.T) {
func TestParseRequest_EosioV1Full(t *testing.T) {
expected := api.NewEosioV1("http://api.example.com", "http://host.example.com", 500)
api, err := ParseRequest("v1|http://api.example.com|1000|http://host.example.com")
@ -51,7 +51,7 @@ func TestParseEosioV1Full(t *testing.T) {
// EosioV2
// --------------------------------
func TestParseEosioV2(t *testing.T) {
func TestParseRequest_EosioV2(t *testing.T) {
expected := api.NewEosioV2("http://api.v2.example.com", "", 10)
api, err := ParseRequest("v2|http://api.v2.example.com")
@ -59,7 +59,7 @@ func TestParseEosioV2(t *testing.T) {
assert.Equal(t, expected.LogInfo(), api.LogInfo())
}
func TestParseEosioV2WithOffset(t *testing.T) {
func TestParseRequest_EosioV2WithOffset(t *testing.T) {
expected := api.NewEosioV2("http://api.v2.example.com", "", 1000)
api, err := ParseRequest("v2|http://api.v2.example.com|1000")
@ -67,7 +67,7 @@ func TestParseEosioV2WithOffset(t *testing.T) {
assert.Equal(t, expected.LogInfo(), api.LogInfo())
}
func TestParseEosioV2Full(t *testing.T) {
func TestParseRequest_EosioV2Full(t *testing.T) {
expected := api.NewEosioV2("http://api.v2.example.com", "http://host.example.com", 1000)
api, err := ParseRequest("v2|http://api.v2.example.com|1000|http://host.example.com")
@ -79,7 +79,7 @@ func TestParseEosioV2Full(t *testing.T) {
// Old contract api (alias for backward compatibility)
// --------------------------------
func TestParseOldContract(t *testing.T) {
func TestParseRequest_OldContract(t *testing.T) {
expected := api.NewAtomicAsset("http://api.contract.example.com", 5)
api, err := ParseRequest("contract|http://api.contract.example.com")
@ -87,7 +87,7 @@ func TestParseOldContract(t *testing.T) {
assert.Equal(t, expected.LogInfo(), api.LogInfo())
}
func TestParseOldContractWithBlockTime(t *testing.T) {
func TestParseRequest_OldContractWithBlockTime(t *testing.T) {
expected := api.NewAtomicAsset("http://api.contract.example.com", 256)
api, err := ParseRequest("contract|http://api.contract.example.com|512")
@ -98,7 +98,7 @@ func TestParseOldContractWithBlockTime(t *testing.T) {
// AtomicAsset
// --------------------------------
func TestParseAtomicAsset(t *testing.T) {
func TestParseRequest_AtomicAsset(t *testing.T) {
expected := api.NewAtomicAsset("http://api.atomicassets.io", 5)
api, err := ParseRequest("atomic|http://api.atomicassets.io")
@ -106,7 +106,7 @@ func TestParseAtomicAsset(t *testing.T) {
assert.Equal(t, expected.LogInfo(), api.LogInfo())
}
func TestParseAtomicAssetWithBlockTime(t *testing.T) {
func TestParseRequest_AtomicAssetWithBlockTime(t *testing.T) {
expected := api.NewAtomicAsset("http://api.atomicassets.io", 256)
api, err := ParseRequest("atomic|http://api.atomicassets.io|512")
@ -114,7 +114,7 @@ func TestParseAtomicAssetWithBlockTime(t *testing.T) {
assert.Equal(t, expected.LogInfo(), api.LogInfo())
}
func TestParseDebugApi(t *testing.T) {
func TestParseRequest_DebugApi(t *testing.T) {
expected := api.NewDebugApi("some_api_call")
api, err := ParseRequest("debug|some_api_call")

View file

@ -2,7 +2,7 @@ package utils
import "testing"
func TestJsonGetInt64(t *testing.T) {
func TestJson_GetInt64(t *testing.T) {
tests := []struct {
name string
input interface{}

View file

@ -7,7 +7,7 @@ import (
log "github.com/inconshreveable/log15"
)
func Test_ParseLogFormatter(t *testing.T) {
func TestParseLogFormatter(t *testing.T) {
tests := []struct {
name string
arg string

View file

@ -7,14 +7,14 @@ import (
"github.com/stretchr/testify/assert"
)
func TestTimeGetTimeWithDefaultValue(t *testing.T) {
func TestTime_GetTimeWithDefaultValue(t *testing.T) {
var ts Time
// Assert that time is NOW (+-10 seconds)
assert.InDelta(t, ts.GetTime().Unix(), time.Now().In(time.UTC).Unix(), float64(10))
}
func TestTimeGetTimeWithSetTime(t *testing.T) {
func TestTime_GetTimeWithSetTime(t *testing.T) {
var ts Time
expected := time.Unix(1048722042, 500)