Documentation ¶
Overview ¶
Package teststore provides storage to be used in tests. All data is only stored in memory.
Index ¶
- type Event
- type Events
- type Recorder
- func (r *Recorder) DeleteResource(ctx context.Context, project string, res *resource.Deployed) error
- func (r *Recorder) GetGraph(ctx context.Context, project string) (*resource.Graph, error)
- func (r *Recorder) ListResources(ctx context.Context, project string) ([]*resource.Deployed, error)
- func (r *Recorder) PutGraph(ctx context.Context, project string, g *resource.Graph) error
- func (r *Recorder) PutResource(ctx context.Context, project string, res *resource.Deployed) error
- type Store
- func (s *Store) DeleteResource(ctx context.Context, project string, res *resource.Deployed) error
- func (s *Store) GetGraph(ctx context.Context, project string) (*resource.Graph, error)
- func (s *Store) ListResources(ctx context.Context, project string) ([]*resource.Deployed, error)
- func (s *Store) PutGraph(ctx context.Context, project string, g *resource.Graph) error
- func (s *Store) PutResource(ctx context.Context, project string, res *resource.Deployed) error
- func (s *Store) SeedGraph(project string, g *resource.Graph)
- func (s *Store) SeedResources(project string, resources []*resource.Deployed)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { Method string // Called method. Project string // Project that was passed in. Data interface{} // Arbitrary data. Content depends on the method. Err error // Error that was returned from call. }
An Event is a recorded event.
type Events ¶
type Events []Event
Events is a collection of events.
func (Events) Diff ¶
Diff returns a diff of events. Returns an empty string if the events are equal.
type Recorder ¶
type Recorder struct { Store store Events Events // contains filtered or unexported fields }
A Recorder acts as a wrapper to a store. It records all transactions with the store for test or debugging purposes.
func (*Recorder) DeleteResource ¶
func (r *Recorder) DeleteResource(ctx context.Context, project string, res *resource.Deployed) error
DeleteResource calls the corresponding method on the underlying store and records the event.
Resource is set as event data.
func (*Recorder) GetGraph ¶
GetGraph calls the corresponding method on the underlying store and records the event.
func (*Recorder) ListResources ¶
ListResources calls the corresponding method on the underlying store and records the event.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a store that's intended to be used in tests. All data is stored in memory.
func (*Store) DeleteResource ¶
DeleteResource deletes a resource. No-op if the resource does not exist.
func (*Store) GetGraph ¶
GetGraph returns a graph for a project. Returns nil if the project does not have a graph.
func (*Store) ListResources ¶
ListResources lists all resources in a project.
func (*Store) PutResource ¶
PutResource creates or updates a resource.
func (*Store) SeedGraph ¶
SeedGraph seeds the store with the graph for a given project. If the project already has a graph, it is overwritten.
The method may be called multiple times to set the graph for multiple projects.
func (*Store) SeedResources ¶
SeedResources seeds the store with resources for a given project. If the project already has resources, resources are added to it.
The method may be called multiple times to add resources in parts, or add resources to different projects.