mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-07-03 11:53:43 +02:00
src/api/eosio_v2.go: Adding EosioV2Factory function
This commit is contained in:
parent
7b78d2632b
commit
9fcffe375a
2 changed files with 20 additions and 0 deletions
|
|
@ -13,6 +13,10 @@ type EosioV2 struct {
|
||||||
offset int64
|
offset int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EosioV2Factory(args ApiArguments) ApiInterface {
|
||||||
|
return NewEosioV2(args.Url, args.Host, int64(args.NumBlocks))
|
||||||
|
}
|
||||||
|
|
||||||
func NewEosioV2(url string, host string, offset int64) EosioV2 {
|
func NewEosioV2(url string, host string, offset int64) EosioV2 {
|
||||||
|
|
||||||
api := EosioV2{
|
api := EosioV2{
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,22 @@ import (
|
||||||
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestEosioV2Factory(t *testing.T) {
|
||||||
|
|
||||||
|
api := EosioV2Factory(ApiArguments{
|
||||||
|
Url: "https://api.v2.example.com",
|
||||||
|
Host: "host.example.com",
|
||||||
|
NumBlocks: 120,
|
||||||
|
})
|
||||||
|
|
||||||
|
expected := NewEosioV2("https://api.v2.example.com", "host.example.com", 120)
|
||||||
|
|
||||||
|
assert.IsType(t, expected, api)
|
||||||
|
assert.Equal(t, expected.client.Url, api.(EosioV2).client.Url)
|
||||||
|
assert.Equal(t, expected.client.Host, api.(EosioV2).client.Host)
|
||||||
|
assert.Equal(t, expected.offset, api.(EosioV2).offset)
|
||||||
|
}
|
||||||
|
|
||||||
func TestEosioV2LogInfo(t *testing.T) {
|
func TestEosioV2LogInfo(t *testing.T) {
|
||||||
|
|
||||||
api := NewEosioV2("https://api.v2.example.com", "host.example.com", 120)
|
api := NewEosioV2("https://api.v2.example.com", "host.example.com", 120)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue