waterquality

package
v0.0.0-...-61e9378 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWQNotFound error = errors.New("not found")

Functions

This section is empty.

Types

type Point

type Point struct {
	Latitude  float64
	Longitude float64
}

func NewPoint

func NewPoint(lat, lon float64) Point

type WaterQuality

type WaterQuality struct {
	ID       string              `json:"id"`
	Location *domain.Point       `json:"location"`
	Latest   domain.WaterQuality `json:"latest"`
	History  *[]domain.Value     `json:"history"`
}

type WaterQualityDTO

type WaterQualityDTO struct {
	ID           string          `json:"id"`
	Location     *domain.Point   `json:"location,omitempty"`
	Temperature  float64         `json:"temperature"`
	Source       *string         `json:"source,omitempty"`
	DateObserved domain.DateTime `json:"dateObserved,omitempty"`
}

type WaterQualityService

type WaterQualityService interface {
	Start(ctx context.Context)
	Refresh(ctx context.Context) (int, error)
	Shutdown(ctx context.Context)

	Tenant() string
	Broker() string

	GetAll(ctx context.Context) []domain.WaterQuality
	GetAllNearPointWithinTimespan(ctx context.Context, pt Point, distance int, from, to time.Time) ([]domain.WaterQuality, error)
	GetByID(ctx context.Context, id string, from, to time.Time) (*domain.WaterQualityTemporal, error)
}

func NewWaterQualityService

func NewWaterQualityService(ctx context.Context, url, tenant string) WaterQualityService

type WaterQualityServiceMock

type WaterQualityServiceMock struct {
	// BrokerFunc mocks the Broker method.
	BrokerFunc func() string

	// GetAllFunc mocks the GetAll method.
	GetAllFunc func(ctx context.Context) []domain.WaterQuality

	// GetAllNearPointWithinTimespanFunc mocks the GetAllNearPointWithinTimespan method.
	GetAllNearPointWithinTimespanFunc func(ctx context.Context, pt Point, distance int, from time.Time, to time.Time) ([]domain.WaterQuality, error)

	// GetByIDFunc mocks the GetByID method.
	GetByIDFunc func(ctx context.Context, id string, from time.Time, to time.Time) (*domain.WaterQualityTemporal, error)

	// RefreshFunc mocks the Refresh method.
	RefreshFunc func(ctx context.Context) (int, error)

	// ShutdownFunc mocks the Shutdown method.
	ShutdownFunc func(ctx context.Context)

	// StartFunc mocks the Start method.
	StartFunc func(ctx context.Context)

	// TenantFunc mocks the Tenant method.
	TenantFunc func() string
	// contains filtered or unexported fields
}

WaterQualityServiceMock is a mock implementation of WaterQualityService.

func TestSomethingThatUsesWaterQualityService(t *testing.T) {

	// make and configure a mocked WaterQualityService
	mockedWaterQualityService := &WaterQualityServiceMock{
		BrokerFunc: func() string {
			panic("mock out the Broker method")
		},
		GetAllFunc: func(ctx context.Context) []domain.WaterQuality {
			panic("mock out the GetAll method")
		},
		GetAllNearPointWithinTimespanFunc: func(ctx context.Context, pt Point, distance int, from time.Time, to time.Time) ([]domain.WaterQuality, error) {
			panic("mock out the GetAllNearPointWithinTimespan method")
		},
		GetByIDFunc: func(ctx context.Context, id string, from time.Time, to time.Time) (*domain.WaterQualityTemporal, error) {
			panic("mock out the GetByID method")
		},
		RefreshFunc: func(ctx context.Context) (int, error) {
			panic("mock out the Refresh method")
		},
		ShutdownFunc: func(ctx context.Context)  {
			panic("mock out the Shutdown method")
		},
		StartFunc: func(ctx context.Context)  {
			panic("mock out the Start method")
		},
		TenantFunc: func() string {
			panic("mock out the Tenant method")
		},
	}

	// use mockedWaterQualityService in code that requires WaterQualityService
	// and then make assertions.

}

func (*WaterQualityServiceMock) Broker

func (mock *WaterQualityServiceMock) Broker() string

Broker calls BrokerFunc.

func (*WaterQualityServiceMock) BrokerCalls

func (mock *WaterQualityServiceMock) BrokerCalls() []struct {
}

BrokerCalls gets all the calls that were made to Broker. Check the length with:

len(mockedWaterQualityService.BrokerCalls())

func (*WaterQualityServiceMock) GetAll

GetAll calls GetAllFunc.

func (*WaterQualityServiceMock) GetAllCalls

func (mock *WaterQualityServiceMock) GetAllCalls() []struct {
	Ctx context.Context
}

GetAllCalls gets all the calls that were made to GetAll. Check the length with:

len(mockedWaterQualityService.GetAllCalls())

func (*WaterQualityServiceMock) GetAllNearPointWithinTimespan

func (mock *WaterQualityServiceMock) GetAllNearPointWithinTimespan(ctx context.Context, pt Point, distance int, from time.Time, to time.Time) ([]domain.WaterQuality, error)

GetAllNearPointWithinTimespan calls GetAllNearPointWithinTimespanFunc.

func (*WaterQualityServiceMock) GetAllNearPointWithinTimespanCalls

func (mock *WaterQualityServiceMock) GetAllNearPointWithinTimespanCalls() []struct {
	Ctx      context.Context
	Pt       Point
	Distance int
	From     time.Time
	To       time.Time
}

GetAllNearPointWithinTimespanCalls gets all the calls that were made to GetAllNearPointWithinTimespan. Check the length with:

len(mockedWaterQualityService.GetAllNearPointWithinTimespanCalls())

func (*WaterQualityServiceMock) GetByID

GetByID calls GetByIDFunc.

func (*WaterQualityServiceMock) GetByIDCalls

func (mock *WaterQualityServiceMock) GetByIDCalls() []struct {
	Ctx  context.Context
	ID   string
	From time.Time
	To   time.Time
}

GetByIDCalls gets all the calls that were made to GetByID. Check the length with:

len(mockedWaterQualityService.GetByIDCalls())

func (*WaterQualityServiceMock) Refresh

func (mock *WaterQualityServiceMock) Refresh(ctx context.Context) (int, error)

Refresh calls RefreshFunc.

func (*WaterQualityServiceMock) RefreshCalls

func (mock *WaterQualityServiceMock) RefreshCalls() []struct {
	Ctx context.Context
}

RefreshCalls gets all the calls that were made to Refresh. Check the length with:

len(mockedWaterQualityService.RefreshCalls())

func (*WaterQualityServiceMock) Shutdown

func (mock *WaterQualityServiceMock) Shutdown(ctx context.Context)

Shutdown calls ShutdownFunc.

func (*WaterQualityServiceMock) ShutdownCalls

func (mock *WaterQualityServiceMock) ShutdownCalls() []struct {
	Ctx context.Context
}

ShutdownCalls gets all the calls that were made to Shutdown. Check the length with:

len(mockedWaterQualityService.ShutdownCalls())

func (*WaterQualityServiceMock) Start

func (mock *WaterQualityServiceMock) Start(ctx context.Context)

Start calls StartFunc.

func (*WaterQualityServiceMock) StartCalls

func (mock *WaterQualityServiceMock) StartCalls() []struct {
	Ctx context.Context
}

StartCalls gets all the calls that were made to Start. Check the length with:

len(mockedWaterQualityService.StartCalls())

func (*WaterQualityServiceMock) Tenant

func (mock *WaterQualityServiceMock) Tenant() string

Tenant calls TenantFunc.

func (*WaterQualityServiceMock) TenantCalls

func (mock *WaterQualityServiceMock) TenantCalls() []struct {
}

TenantCalls gets all the calls that were made to Tenant. Check the length with:

len(mockedWaterQualityService.TenantCalls())

type WaterQualityTemporalDTO

type WaterQualityTemporalDTO struct {
	ID           string          `json:"id"`
	Temperature  []domain.Value  `json:"temperature"`
	Source       *string         `json:"source,omitempty"`
	DateObserved domain.DateTime `json:"dateObserved,omitempty"`
}

Jump to

Keyboard shortcuts

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