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 ¶
- func FloatBetween(a, b float64) float64
- func FourierSineGen(current, period, step, min, max float64, params ...float64) func() float64
- func RandReading(userEmail, core string, posted time.Time) models.Reading
- func ReadingGen(userEmail, coreID string, current time.Time, step time.Duration) func() models.Reading
- func Translator(a, b, c, d float64) func(float64) float64
- type Oauth
- type ReadingStore
- func (f *ReadingStore) DeleteReadings(core string, start, end time.Time) error
- func (f *ReadingStore) GetLatestReadings(userEmail string) (readings []models.Reading, err error)
- func (f *ReadingStore) GetReadings(core string, start, end time.Time) ([]models.Reading, error)
- func (f *ReadingStore) StoreReading(reading models.Reading) error
- type SecretStore
- type UserStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FloatBetween ¶
FloatBetween returns a random float value between a and b
func FourierSineGen ¶
FourierSineGen returns a function that generates sequential values in a fourier sine series given the input parameters.
func RandReading ¶
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 ¶
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 ¶
GetCallbackCsrfToken is a fake implementation of oauth GetCallbackCsrfToken
func (*Oauth) GetExchangeToken ¶
GetExchangeToken is a fake implementation of oauth GetExchangeToken
func (*Oauth) GetRedirectURL ¶
GetRedirectURL is a fake implementation of oauth GetRedirectURL
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 ¶
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 ¶
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.