fake

package
v0.0.0-...-6f84274 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fake provides a fake weather client for testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*Config
}

Client ...

func NewClient

func NewClient(options map[string]any) (*Client, error)

NewClient creates a new client that will return fake data based on configuration. This is intended for testing purposes only and should be used in a staging environment or integration tests, not as a mock in unit tests

func (*Client) GetAverageHighTemperature

func (c *Client) GetAverageHighTemperature(_ context.Context, _ time.Duration) (float32, error)

GetAverageHighTemperature returns the configured value

func (*Client) GetTotalRain

func (c *Client) GetTotalRain(_ context.Context, since time.Duration) (float32, error)

GetTotalRain calculates and returns the configured amount of rain for the given period

type Config

type Config struct {
	RainMM       float32 `mapstructure:"rain_mm"`
	RainInterval string  `mapstructure:"rain_interval"`

	AverageHighTemperature float32 `mapstructure:"avg_high_temperature"`

	Error string `mapstructure:"error"`
	// contains filtered or unexported fields
}

Config is specific to the Fake API and holds all of the necessary fields for configuring fake data responses.

Jump to

Keyboard shortcuts

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