mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-19 05:10:02 +02:00
src/api/eosio_v1.go: Adding EosioV1Factory function
This commit is contained in:
parent
39927a2441
commit
7b78d2632b
2 changed files with 20 additions and 0 deletions
|
|
@ -14,6 +14,10 @@ type EosioV1 struct {
|
|||
block_time float64
|
||||
}
|
||||
|
||||
func EosioV1Factory(args ApiArguments) ApiInterface {
|
||||
return NewEosioV1(args.Url, args.Host, float64(args.NumBlocks / 2))
|
||||
}
|
||||
|
||||
func NewEosioV1(url string, host string, block_time float64) EosioV1 {
|
||||
|
||||
api := EosioV1{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,22 @@ import (
|
|||
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
||||
)
|
||||
|
||||
func TestEosioV1Factory(t *testing.T) {
|
||||
|
||||
api := EosioV1Factory(ApiArguments{
|
||||
Url: "https://api.v1.example.com",
|
||||
Host: "host.example.com",
|
||||
NumBlocks: 120,
|
||||
})
|
||||
|
||||
expected := NewEosioV1("https://api.v1.example.com", "host.example.com", 60)
|
||||
|
||||
assert.IsType(t, expected, api)
|
||||
assert.Equal(t, expected.client.Url, api.(EosioV1).client.Url)
|
||||
assert.Equal(t, expected.client.Host, api.(EosioV1).client.Host)
|
||||
assert.Equal(t, expected.block_time, api.(EosioV1).block_time)
|
||||
}
|
||||
|
||||
func TestEosioV1LogInfo(t *testing.T) {
|
||||
|
||||
api := NewEosioV1("https://api.v1.example.com", "host.example.com", 120)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue