Documentation ¶
Overview ¶
Package teststate provides test-only implementation for state-specific interfaces.
Index ¶
- Constants
- Variables
- type Item
- type ItemSyncer
- func (s *ItemSyncer) Count() int
- func (s *ItemSyncer) CountDeletes() int
- func (s *ItemSyncer) Delete(item persist.MarshallableItem) error
- func (s *ItemSyncer) LoadAll() ([]persist.MarshallableItem, error)
- func (s *ItemSyncer) LoadByID(id string) (persist.MarshallableItem, error)
- func (s *ItemSyncer) WasRequested(id string) bool
- func (s *ItemSyncer) Write(item persist.MarshallableItem) error
Constants ¶
const (
// Type is the type of an Item.
Type = "test-type"
)
Variables ¶
var ( // Item1 is an Item with ID 1. Item1 = NewItem("1") // Item2 is an Item with ID 2. Item2 = NewItem("2") )
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct { // I is the item's ID. I string // S represents whether the Marshal operation on this object will be successful. S bool }
Item implements persist.MarshallableItem and MarshallableQueueItem interfaces for testing.
type ItemSyncer ¶
type ItemSyncer struct {
// contains filtered or unexported fields
}
ItemSyncer implements the persist.ItemSyncer interface using a map. It tracks the LoadByID requests made to the syncer in the form of an internal `reqs` map for testing purposes.
func NewItemSyncerWithDelete ¶
func NewItemSyncerWithDelete(delete bool) *ItemSyncer
NewItemSyncerWithDelete initializes the ItemSyncer with a value for whether to delete items or not.
func (*ItemSyncer) Count ¶
func (s *ItemSyncer) Count() int
Count returns number of elements in the syncer for testing.
func (*ItemSyncer) CountDeletes ¶
func (s *ItemSyncer) CountDeletes() int
CountDeletes returns the number of deletions requested.
func (*ItemSyncer) Delete ¶
func (s *ItemSyncer) Delete(item persist.MarshallableItem) error
Delete deletes an item from the map.
func (*ItemSyncer) LoadAll ¶
func (s *ItemSyncer) LoadAll() ([]persist.MarshallableItem, error)
LoadAll returns a slice of all the items in the map, sorted by id.
func (*ItemSyncer) LoadByID ¶
func (s *ItemSyncer) LoadByID(id string) (persist.MarshallableItem, error)
LoadByID returns an item in the map with the provided id, if it exists.
func (*ItemSyncer) WasRequested ¶
func (s *ItemSyncer) WasRequested(id string) bool
WasRequested returns whether LoadByID was ever called with a specific id.
func (*ItemSyncer) Write ¶
func (s *ItemSyncer) Write(item persist.MarshallableItem) error
Write writes an item to the map.