picker

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

package picker provided structures and method to manage injected variable system for Godog.

It allows an user to pick value into a store and inject them in steps through a variable replacement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug()

Debug activate debug logs.

func NewReplacer

func NewReplacer(store *Store) func(step *messages.Pickle_PickleStep)

NewReplacer provides function to replace picked variables in messages.Pickle_PickleStep Text and Arguments.

func NoLog

func NoLog()

NoLog disable logging under Fatal level.

func Reset

func Reset()

Reset matcher instance.

func ResetLog

func ResetLog()

ResetLog activate debug logs.

Types

type DataScope

type DataScope int

DataScope encourages to use provided constants for data scope storage.

const (
	// PersistentValue allows to store data in persistent store.
	PersistentValue DataScope = iota + 1
	// DisposableValue allows to store data in disposable store.
	DisposableValue
	// InstanceValue allows to store data in in instance store.
	// An instance is defined by a Key, a Kind and a Value (interface).
	// It can only store Kactus feature or internal instances.
	InstanceValue
)

type InstanceItem

type InstanceItem struct {
	Kind     InstanceKind
	Instance interface{}
}

InstanceItem describe a kactus tool instance.

type InstanceKind

type InstanceKind int

InstanceKind encourages user to pass by instance constant when providing instance kind.

const (
	// NoInstance is returned when
	// failed to retrieve instance from store.
	NoInstance InstanceKind = iota

	// Postgres kind refers to postgres.DB instance
	Postgres

	// GCP kind refers to pubsub.GCP instance
	GCP

	// REST refers to http.?? instance
	REST

	// Fixture refers to fixtures.Fixtures instance
	Fixture
)

type InstanceStore

type InstanceStore map[string]InstanceItem

InstanceStore represents the structure used by Store to manage kactus tools instances.

type KeyValueStore

type KeyValueStore map[string]interface{}

KeyValueStore abstract management of values in store.

type SeedManifest

type SeedManifest struct {
	Persistent map[string]interface{} `yaml:"persistent"`
	Disposable map[string]interface{} `yaml:"disposable"`
}

SeedManifest represents the YAML structure to load data into store.

func (*SeedManifest) Load

func (s *SeedManifest) Load(store *Store) error

Load parse SeedManifest and stores provided data.

type Store

type Store struct {
	// Disposable stores picked data that will be forgotten on resets.
	Disposable KeyValueStore

	// Persistent stores picked data for all suite duration.
	Persistent KeyValueStore

	// Instance stores picked data as instance values.
	Instance InstanceStore
}

Store picked data.

func NewStore

func NewStore() *Store

NewStore initialize picker store.

func (*Store) Del

func (store *Store) Del(key string, scope DataScope)

Del remove known key from Disposable or Persistent value.

func (*Store) Get

func (store *Store) Get(key string) (value interface{}, exists bool)

Get tries to retrieve stored values. If key is known in both Disposable and Persistent values, it will return the Disposable one.

func (*Store) GetInstance

func (store *Store) GetInstance(key string) (kind InstanceKind, instance interface{}, exists bool)

GetInstance retrieves known kactus instance from picker.

func (*Store) Inject

func (store *Store) Inject(inTo interface{}) interface{}

Inject returns value corresponding to element if element matches injectRegex. Else, returns provided value.

func (*Store) InjectAll

func (store *Store) InjectAll(inTo string) string

InjectAll parses provided string using findAllInjectionRegex and replace injected values using Inject method.

func (*Store) Pick

func (store *Store) Pick(key string, value interface{}, scope DataScope)

Pick store value under key. Providing a true bool to noReset will store value in persistent store.

func (*Store) Reset

func (store *Store) Reset()

Reset stored Disposable values. It always returns nil but requires error for godog usage.

Jump to

Keyboard shortcuts

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