locatetest

package
v0.14.33 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLocateServer

func NewLocateServer(loc *Locator) *httptest.Server

NewLocateServer creates an httptest.Server that can respond to Locate API v2 requests. Useful for unit testing.

func NewLocateServerV2 added in v0.11.0

func NewLocateServerV2(loc *LocatorV2) *httptest.Server

NewLocateServerV2 creates an httptest.Server that can respond to Locate API V2 requests using a LocatorV2. Uselful for unit testing. TODO(cristinaleon): once the LocatorV2 replaces the Locator, leave only one implementation.

Types

type Locator

type Locator struct {
	Servers []string
	Err     error
}

Locator is a fake Locator interface that returns the configured Servers or Err.

func (*Locator) Nearest

func (l *Locator) Nearest(ctx context.Context, service, lat, lon string) ([]v2.Target, error)

Nearest returns the pre-configured Locator Servers or Err.

type LocatorV2 added in v0.11.0

type LocatorV2 struct {
	heartbeat.StatusTracker
	Servers []string
	Err     error
}

LocatorV2 is a fake LocatorV2 implementation that returns the configured Servers or Err.

func (*LocatorV2) Nearest added in v0.11.0

func (l *LocatorV2) Nearest(service string, lat, lon float64, opts *heartbeat.NearestOptions) (*heartbeat.TargetInfo, error)

Nearest returns the pre-configured LocatorV2 Servers or Err.

type Signer

type Signer struct{}

Signer implements the Signer interface for unit tests.

func (*Signer) Sign

func (s *Signer) Sign(cl jwt.Claims) (string, error)

Sign creates a fake signature using the given claims.

Jump to

Keyboard shortcuts

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