teststore

package
v0.0.0-...-1eb86f4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package teststore provides storage to be used in tests. All data is only stored in memory.

Index

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.

func (Event) Equals

func (ev Event) Equals(other Event) bool

Equals returns true if the two events are equal.

func (Event) String

func (ev Event) String() string

type Events

type Events []Event

Events is a collection of events.

func (Events) Diff

func (ee Events) Diff(other Events) string

Diff returns a diff of events. Returns an empty string if the events are equal.

func (Events) Equals

func (ee Events) Equals(other Events) bool

Equals returns true if the events match other events.

func (Events) String

func (ee Events) String() string

String returns a string of all events that have occurred.

If no events have been recorded, returns

<no events>

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

func (r *Recorder) GetGraph(ctx context.Context, project string) (*resource.Graph, error)

GetGraph calls the corresponding method on the underlying store and records the event.

func (*Recorder) ListResources

func (r *Recorder) ListResources(ctx context.Context, project string) ([]*resource.Deployed, error)

ListResources calls the corresponding method on the underlying store and records the event.

func (*Recorder) PutGraph

func (r *Recorder) PutGraph(ctx context.Context, project string, g *resource.Graph) error

PutGraph calls the corresponding method on the underlying store and records the event.

func (*Recorder) PutResource

func (r *Recorder) PutResource(ctx context.Context, project string, res *resource.Deployed) error

PutResource calls the corresponding method on the underlying store and records the event.

Resource is set as event data.

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

func (s *Store) DeleteResource(ctx context.Context, project string, res *resource.Deployed) error

DeleteResource deletes a resource. No-op if the resource does not exist.

func (*Store) GetGraph

func (s *Store) GetGraph(ctx context.Context, project string) (*resource.Graph, error)

GetGraph returns a graph for a project. Returns nil if the project does not have a graph.

func (*Store) ListResources

func (s *Store) ListResources(ctx context.Context, project string) ([]*resource.Deployed, error)

ListResources lists all resources in a project.

func (*Store) PutGraph

func (s *Store) PutGraph(ctx context.Context, project string, g *resource.Graph) error

PutGraph creates or updates a graph.

func (*Store) PutResource

func (s *Store) PutResource(ctx context.Context, project string, res *resource.Deployed) error

PutResource creates or updates a resource.

func (*Store) SeedGraph

func (s *Store) SeedGraph(project string, g *resource.Graph)

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

func (s *Store) SeedResources(project string, resources []*resource.Deployed)

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.

Jump to

Keyboard shortcuts

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