fake

package
v0.0.0-...-721f978 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fake is a collection of in-memory or stand-in implementations of various interfaces in the project for usage in unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FloatBetween

func FloatBetween(a, b float64) float64

FloatBetween returns a random float value between a and b

func FourierSineGen

func FourierSineGen(current, period, step, min, max float64, params ...float64) func() float64

FourierSineGen returns a function that generates sequential values in a fourier sine series given the input parameters.

func RandReading

func RandReading(userEmail, core string, posted time.Time) models.Reading

RandReading returns a reading with specified userEmail, core, and posted time and other reading values set to random values within a reasonable range.

func ReadingGen

func ReadingGen(userEmail, coreID string, current time.Time, step time.Duration) func() models.Reading

ReadingGen returns a function; the returned function generates readings with the input userEmail and coreid that start at the input current time and iterate in values of step. The values for temperature, humidity, etc. follow a fourier sine series that stays within reasonable values. The main point of this is to generate test values that will yield a visuably reasonable graph.

func Translator

func Translator(a, b, c, d float64) func(float64) float64

Translator returns a function that translates input floats from linear domain a-b to domain c-d.

Types

type Oauth

type Oauth struct {
	Email string
}

Oauth specifies a fake oauth handler for use in unit tests of higher level libraries.

func (*Oauth) GetCallbackCsrfToken

func (f *Oauth) GetCallbackCsrfToken(r *http.Request) string

GetCallbackCsrfToken is a fake implementation of oauth GetCallbackCsrfToken

func (*Oauth) GetExchangeToken

func (f *Oauth) GetExchangeToken(r *http.Request) (*oauth2.Token, error)

GetExchangeToken is a fake implementation of oauth GetExchangeToken

func (*Oauth) GetRedirectURL

func (f *Oauth) GetRedirectURL(csrftoken string) string

GetRedirectURL is a fake implementation of oauth GetRedirectURL

func (*Oauth) GetUserData

func (f *Oauth) GetUserData(tok *oauth2.Token) (models.User, error)

GetUserData is a fake implementation of oauth GetUserData

type ReadingStore

type ReadingStore struct {
	// contains filtered or unexported fields
}

ReadingStore is a fake implementation of the models.ReadingStore interface via an in memory slice. It is used for unit tests of libraries that accept a models.ReadingStore interface.

func (*ReadingStore) DeleteReadings

func (f *ReadingStore) DeleteReadings(core string, start, end time.Time) error

DeleteReadings is a placeholder to fulfill the models.ReadingStore interface

func (*ReadingStore) GetLatestReadings

func (f *ReadingStore) GetLatestReadings(userEmail string) (readings []models.Reading, err error)

GetLatestReadings is a placeholder to fulfill the models.ReadingStore interface

func (*ReadingStore) GetReadings

func (f *ReadingStore) GetReadings(core string, start, end time.Time) ([]models.Reading, error)

GetReadings returns readings in its slice of readings that lie between the specified start and end time.

func (*ReadingStore) StoreReading

func (f *ReadingStore) StoreReading(reading models.Reading) error

StoreReading appends the reading to its slice of readings

type SecretStore

type SecretStore map[string]models.Secret

SecretStore implements the models.SecretStore interface for use in unit tests of libraries that accept a models.SecretStore. Implemented via an in memory map.

func (SecretStore) GetSecret

func (s SecretStore) GetSecret(userEmail string) (models.Secret, error)

GetSecret returns the secret for given userEmail.

func (SecretStore) StoreSecret

func (s SecretStore) StoreSecret(userEmail string, secret models.Secret) error

StoreSecret updates/inserts a secret for the given userEmail.

type UserStore

type UserStore map[string]models.User

UserStore implements the models.UserStore interface for use in testing libraries that use a models.UserStore.

func (UserStore) GetUser

func (u UserStore) GetUser(email string) (models.User, error)

GetUser returns the user data for the given user email.

func (UserStore) StoreUser

func (u UserStore) StoreUser(user models.User) error

StoreUser inserts/updates data for the given user.

Jump to

Keyboard shortcuts

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