dstest

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package dstest implements a mock Dark Sky server for testing.

Index

Constants

View Source
const DefaultKey = "key"

DefaultKey is the default key.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

An Option sets an option on a Server.

func WithDefaultForecasts

func WithDefaultForecasts() Option

WithDefaultForecasts returns an option that adds all default forecasts to a Server.

func WithForecast

func WithForecast(request Request, forecastStr string) Option

WithForecast returns an option that adds a forecastStr as a response to request on a Server.

type Request

type Request struct {
	Latitude  float64
	Longitude float64
	Time      darksky.Time
	Exclude   string // A string, not a []darksky.Block so we can use Request as a map key.
	Extend    darksky.Extend
	Lang      darksky.Lang
	Units     darksky.Units
}

A Request contains parameters for a request.

func (*Request) Options

func (r *Request) Options() *darksky.ForecastOptions

Options returns a new darksky.ForecastOptions constructed from r.

type Server

type Server struct {
	*httptest.Server
	chi.Router
	Key       string
	Forecasts map[Request]string
}

A Server is a mock server.

func NewServer

func NewServer(options ...Option) *Server

NewServer returns a new Server.

func (*Server) NewClient

func (s *Server) NewClient(options ...darksky.ClientOption) (*darksky.Client, error)

NewClient returns a new darksky.Client that connects to s.

Jump to

Keyboard shortcuts

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