testutil

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(tb testing.TB, condition bool, msg string, v ...interface{})

assert fails the test if the condition is false.

func Equals

func Equals(tb testing.TB, exp, act interface{})

equals fails the test if exp is not equal to act.

func ExpectMetricCount added in v0.1.0

func ExpectMetricCount(t *testing.T, c prometheus.Collector, expected int, expectedMetrics ...string)

func ExpectMetrics added in v0.1.0

func ExpectMetrics(t *testing.T, c prometheus.Collector, fixture string, expectedMetrics ...string)

func GetFixturePath

func GetFixturePath(fixture string) string

func NewCollectorTestDb added in v0.1.0

func NewCollectorTestDb() (string, map[string]*data.WatchItem)

createCollectorTestDb creates a test database with two watch items and returns the UUID of the second item and the database.

func NewTestItem

func NewTestItem(title string, price float64, currency string, checkCount int, fetchTime float64, alertCount int) (string, *data.WatchItem)

func NewWatchDb

func NewWatchDb(numItems int) map[string]*data.WatchItem

func Ok

func Ok(tb testing.TB, err error)

ok fails the test if an err is not nil.

Types

type ApiTestServer

type ApiTestServer struct {
	Server  *httptest.Server
	Options ApiTestServerOptions
	// contains filtered or unexported fields
}

func CreateTestApiServer

func CreateTestApiServer(t *testing.T, watches map[string]*data.WatchItem, options ...ApiTestServerOption) *ApiTestServer

func (*ApiTestServer) Close

func (s *ApiTestServer) Close()

func (*ApiTestServer) URL

func (s *ApiTestServer) URL() string

type ApiTestServerOption added in v0.1.0

type ApiTestServerOption func(*ApiTestServerOptions)

func WithPricesAsArray added in v0.1.0

func WithPricesAsArray() ApiTestServerOption

func WithSystemInfo added in v0.1.0

func WithSystemInfo(info *data.SystemInfo) ApiTestServerOption

type ApiTestServerOptions added in v0.1.0

type ApiTestServerOptions struct {
	fmt.Stringer
	PricesAsArray bool
	SystemInfo    *data.SystemInfo
}

func (ApiTestServerOptions) String added in v0.1.0

func (o ApiTestServerOptions) String() string

Jump to

Keyboard shortcuts

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