testutils

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Copyright (c) of parts are held by the various contributors (see the CLA) Licensed under the MIT License. See LICENSE file in the project root for full license information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlwaysOnePolling added in v0.2.0

func AlwaysOnePolling() *polling.DataSources

AlwaysOnePolling returns 1 for all prices

func GetClientWithFixedResp

func GetClientWithFixedResp(resp []byte) *http.Client

GetClientWithFixedResp will return a client that no matter what the request is, will always respond with the 'resp' as the body. From http://hassansin.github.io/Unit-Testing-http-client-in-Go

func NewHTTPServerWithFixedResp

func NewHTTPServerWithFixedResp(port int, resp []byte) *http.Server

NewHTTPServerWithFixedResp will only return the fixed reponse, always

func NewTestClient

func NewTestClient(fn RoundTripFunc) *http.Client

NewTestClient returns *http.Client with Transport replaced to avoid making real calls

func PriceCheck added in v0.2.0

func PriceCheck(asset string, rate float64) error

PriceCheck checks if the price is "reasonable" to see if we inverted the prices

Types

type RoundTripFunc

type RoundTripFunc func(req *http.Request) *http.Response

RoundTripFunc .

func (RoundTripFunc) RoundTrip

func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip .

type UnitTestDataSource added in v0.2.0

type UnitTestDataSource struct {
	Value      float64
	Assets     []string
	SourceName string

	// How to timestamp price quotes
	Timestamp func() time.Time
}

UnitTestDataSource just reports the Value for the supported Assets

func NewUnitTestDataSource added in v0.2.0

func NewUnitTestDataSource(config *config.Config) (*UnitTestDataSource, error)

func (*UnitTestDataSource) FetchPegPrice added in v0.2.0

func (d *UnitTestDataSource) FetchPegPrice(peg string) (i polling.PegItem, err error)

func (*UnitTestDataSource) FetchPegPrices added in v0.2.0

func (d *UnitTestDataSource) FetchPegPrices() (peg polling.PegAssets, err error)

func (*UnitTestDataSource) Name added in v0.2.0

func (d *UnitTestDataSource) Name() string

func (*UnitTestDataSource) SupportedPegs added in v0.2.0

func (d *UnitTestDataSource) SupportedPegs() []string

func (*UnitTestDataSource) Url added in v0.2.0

func (d *UnitTestDataSource) Url() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL