mocks

package
v0.0.0-...-00b7e7e Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package mocks contains code to mock an external service via an *http.Client and generated code for mocking *storage.Instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockedService

func NewMockedService(handler http.Handler) *http.Client

NewMockedService returns an *http.Client that calls the passed handler for all HTTP requests

Types

type MockStorageInstance

type MockStorageInstance struct {
	mock.Mock
}

MockStorageInstance is an autogenerated mock type for the StorageInstance type

func (*MockStorageInstance) GetOrder

func (_m *MockStorageInstance) GetOrder(ctx context.Context, id string) (storage.Order, error)

GetOrder provides a mock function with given fields: ctx, id

func (*MockStorageInstance) GetOrders

func (_m *MockStorageInstance) GetOrders(ctx context.Context, status storage.OrderStatus) ([]storage.Order, error)

GetOrders provides a mock function with given fields: ctx, status

func (*MockStorageInstance) InsertOrder

func (_m *MockStorageInstance) InsertOrder(ctx context.Context, order storage.Order) (string, error)

InsertOrder provides a mock function with given fields: ctx, order

func (*MockStorageInstance) SetOrderStatus

func (_m *MockStorageInstance) SetOrderStatus(ctx context.Context, id string, status storage.OrderStatus) error

SetOrderStatus provides a mock function with given fields: ctx, id, status

type StorageInstance

type StorageInstance interface {
	// GetOrder should return the order with the given ID. If that ID isn't found then
	// the special ErrOrderNotFound error should be returned.
	GetOrder(ctx context.Context, id string) (storage.Order, error)
	// GetOrders should return all orders with the given status. If status is the
	// special -1 value then it should return all orders regardless of their status.
	GetOrders(ctx context.Context, status storage.OrderStatus) ([]storage.Order, error)
	// SetOrderStatus should update the order with the given ID and set the status
	// field. If that ID isn't found then the special ErrOrderNotFound error should
	// be returned.
	SetOrderStatus(ctx context.Context, id string, status storage.OrderStatus) error
	// InsertOrder should fill in the order's ID with a unique identifier if it's not
	// already set and then insert it into the database. It should return the order's
	// ID. If the order already exists then ErrOrderExists should be returned.
	InsertOrder(ctx context.Context, order storage.Order) (string, error)
}

StorageInstance allows us to mock *storage.Instance in the api package

Jump to

Keyboard shortcuts

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