Back to godoc.org

Package env

v0.6.3
Latest Go to latest

The latest major version is .

Published: Jan 30, 2019 | License: BSD-3-Clause | Module: github.com/shisa-platform/core

Index

Variables

var (
	NameNotSet = merry.New("name not set")
	NameEmpty  = merry.New("name has empty value")
)
var (
	DefaultProvider = NewSystem()
)

func Get

func Get(name string) (string, merry.Error)

func GetBool

func GetBool(name string) (bool, merry.Error)

func GetInt

func GetInt(name string) (int, merry.Error)

type FakeProvider

type FakeProvider struct {
	GetHook     func(string) (string, merry.Error)
	GetIntHook  func(string) (int, merry.Error)
	GetBoolHook func(string) (bool, merry.Error)
	MonitorHook func(string, chan<- Value)

	GetCalls     []*ProviderGetInvocation
	GetIntCalls  []*ProviderGetIntInvocation
	GetBoolCalls []*ProviderGetBoolInvocation
	MonitorCalls []*ProviderMonitorInvocation
}

FakeProvider is a mock implementation of Provider for testing. Use it in your tests as in this example:

package example

func TestWithProvider(t *testing.T) {
	f := &env.FakeProvider{
		GetHook: func(ident1 string) (ident2 string, ident3 merry.Error) {
			// ensure parameters meet expections, signal errors using t, etc
			return
		},
	}

	// test code goes here ...

	// assert state of FakeGet ...
	f.AssertGetCalledOnce(t)
}

Create anonymous function implementations for only those interface methods that should be called in the code under test. This will force a panic if any unexpected calls are made to FakeGet.

func NewFakeProviderDefaultError

func NewFakeProviderDefaultError(t ProviderTestingT) *FakeProvider

NewFakeProviderDefaultError returns an instance of FakeProvider with all hooks configured to call t.Error

func NewFakeProviderDefaultFatal

func NewFakeProviderDefaultFatal(t ProviderTestingT) *FakeProvider

NewFakeProviderDefaultFatal returns an instance of FakeProvider with all hooks configured to call t.Fatal

func NewFakeProviderDefaultPanic

func NewFakeProviderDefaultPanic() *FakeProvider

NewFakeProviderDefaultPanic returns an instance of FakeProvider with all hooks configured to panic

func (*FakeProvider) AssertGetBoolCalled

func (f *FakeProvider) AssertGetBoolCalled(t ProviderTestingT)

AssertGetBoolCalled calls t.Error if FakeProvider.GetBool was not called

func (*FakeProvider) AssertGetBoolCalledN

func (f *FakeProvider) AssertGetBoolCalledN(t ProviderTestingT, n int)

AssertGetBoolCalledN calls t.Error if FakeProvider.GetBool was called less than n times

func (*FakeProvider) AssertGetBoolCalledOnce

func (f *FakeProvider) AssertGetBoolCalledOnce(t ProviderTestingT)

AssertGetBoolCalledOnce calls t.Error if FakeProvider.GetBool was not called exactly once

func (*FakeProvider) AssertGetBoolCalledOnceWith

func (_f29 *FakeProvider) AssertGetBoolCalledOnceWith(t ProviderTestingT, ident1 string)

AssertGetBoolCalledOnceWith calls t.Error if FakeProvider.GetBool was not called exactly once with the given values

func (*FakeProvider) AssertGetBoolCalledWith

func (_f27 *FakeProvider) AssertGetBoolCalledWith(t ProviderTestingT, ident1 string)

AssertGetBoolCalledWith calls t.Error if FakeProvider.GetBool was not called with the given values

func (*FakeProvider) AssertGetBoolNotCalled

func (f *FakeProvider) AssertGetBoolNotCalled(t ProviderTestingT)

AssertGetBoolNotCalled calls t.Error if FakeProvider.GetBool was called

func (*FakeProvider) AssertGetCalled

func (f *FakeProvider) AssertGetCalled(t ProviderTestingT)

AssertGetCalled calls t.Error if FakeProvider.Get was not called

func (*FakeProvider) AssertGetCalledN

func (f *FakeProvider) AssertGetCalledN(t ProviderTestingT, n int)

AssertGetCalledN calls t.Error if FakeProvider.Get was called less than n times

func (*FakeProvider) AssertGetCalledOnce

func (f *FakeProvider) AssertGetCalledOnce(t ProviderTestingT)

AssertGetCalledOnce calls t.Error if FakeProvider.Get was not called exactly once

func (*FakeProvider) AssertGetCalledOnceWith

func (_f9 *FakeProvider) AssertGetCalledOnceWith(t ProviderTestingT, ident1 string)

AssertGetCalledOnceWith calls t.Error if FakeProvider.Get was not called exactly once with the given values

func (*FakeProvider) AssertGetCalledWith

func (_f7 *FakeProvider) AssertGetCalledWith(t ProviderTestingT, ident1 string)

AssertGetCalledWith calls t.Error if FakeProvider.Get was not called with the given values

func (*FakeProvider) AssertGetIntCalled

func (f *FakeProvider) AssertGetIntCalled(t ProviderTestingT)

AssertGetIntCalled calls t.Error if FakeProvider.GetInt was not called

func (*FakeProvider) AssertGetIntCalledN

func (f *FakeProvider) AssertGetIntCalledN(t ProviderTestingT, n int)

AssertGetIntCalledN calls t.Error if FakeProvider.GetInt was called less than n times

func (*FakeProvider) AssertGetIntCalledOnce

func (f *FakeProvider) AssertGetIntCalledOnce(t ProviderTestingT)

AssertGetIntCalledOnce calls t.Error if FakeProvider.GetInt was not called exactly once

func (*FakeProvider) AssertGetIntCalledOnceWith

func (_f19 *FakeProvider) AssertGetIntCalledOnceWith(t ProviderTestingT, ident1 string)

AssertGetIntCalledOnceWith calls t.Error if FakeProvider.GetInt was not called exactly once with the given values

func (*FakeProvider) AssertGetIntCalledWith

func (_f17 *FakeProvider) AssertGetIntCalledWith(t ProviderTestingT, ident1 string)

AssertGetIntCalledWith calls t.Error if FakeProvider.GetInt was not called with the given values

func (*FakeProvider) AssertGetIntNotCalled

func (f *FakeProvider) AssertGetIntNotCalled(t ProviderTestingT)

AssertGetIntNotCalled calls t.Error if FakeProvider.GetInt was called

func (*FakeProvider) AssertGetNotCalled

func (f *FakeProvider) AssertGetNotCalled(t ProviderTestingT)

AssertGetNotCalled calls t.Error if FakeProvider.Get was called

func (*FakeProvider) AssertMonitorCalled

func (f *FakeProvider) AssertMonitorCalled(t ProviderTestingT)

AssertMonitorCalled calls t.Error if FakeProvider.Monitor was not called

func (*FakeProvider) AssertMonitorCalledN

func (f *FakeProvider) AssertMonitorCalledN(t ProviderTestingT, n int)

AssertMonitorCalledN calls t.Error if FakeProvider.Monitor was called less than n times

func (*FakeProvider) AssertMonitorCalledOnce

func (f *FakeProvider) AssertMonitorCalledOnce(t ProviderTestingT)

AssertMonitorCalledOnce calls t.Error if FakeProvider.Monitor was not called exactly once

func (*FakeProvider) AssertMonitorCalledOnceWith

func (_f35 *FakeProvider) AssertMonitorCalledOnceWith(t ProviderTestingT, ident1 string, ident2 chan<- Value)

AssertMonitorCalledOnceWith calls t.Error if FakeProvider.Monitor was not called exactly once with the given values

func (*FakeProvider) AssertMonitorCalledWith

func (_f33 *FakeProvider) AssertMonitorCalledWith(t ProviderTestingT, ident1 string, ident2 chan<- Value)

AssertMonitorCalledWith calls t.Error if FakeProvider.Monitor was not called with the given values

func (*FakeProvider) AssertMonitorNotCalled

func (f *FakeProvider) AssertMonitorNotCalled(t ProviderTestingT)

AssertMonitorNotCalled calls t.Error if FakeProvider.Monitor was called

func (*FakeProvider) Get

func (_f1 *FakeProvider) Get(ident1 string) (ident2 string, ident3 merry.Error)

func (*FakeProvider) GetBool

func (_f21 *FakeProvider) GetBool(ident1 string) (ident2 bool, ident3 merry.Error)

func (*FakeProvider) GetBoolCalled

func (f *FakeProvider) GetBoolCalled() bool

GetBoolCalled returns true if FakeProvider.GetBool was called

func (*FakeProvider) GetBoolCalledN

func (f *FakeProvider) GetBoolCalledN(n int) bool

GetBoolCalledN returns true if FakeProvider.GetBool was called at least n times

func (*FakeProvider) GetBoolCalledOnce

func (f *FakeProvider) GetBoolCalledOnce() bool

GetBoolCalledOnce returns true if FakeProvider.GetBool was called exactly once

func (*FakeProvider) GetBoolCalledOnceWith

func (_f28 *FakeProvider) GetBoolCalledOnceWith(ident1 string) bool

GetBoolCalledOnceWith returns true if FakeProvider.GetBool was called exactly once with the given values

func (*FakeProvider) GetBoolCalledWith

func (_f26 *FakeProvider) GetBoolCalledWith(ident1 string) (found bool)

GetBoolCalledWith returns true if FakeProvider.GetBool was called with the given values

func (*FakeProvider) GetBoolNotCalled

func (f *FakeProvider) GetBoolNotCalled() bool

GetBoolNotCalled returns true if FakeProvider.GetBool was not called

func (*FakeProvider) GetBoolResultsForCall

func (_f30 *FakeProvider) GetBoolResultsForCall(ident1 string) (ident2 bool, ident3 merry.Error, found bool)

GetBoolResultsForCall returns the result values for the first call to FakeProvider.GetBool with the given values

func (*FakeProvider) GetCalled

func (f *FakeProvider) GetCalled() bool

GetCalled returns true if FakeProvider.Get was called

func (*FakeProvider) GetCalledN

func (f *FakeProvider) GetCalledN(n int) bool

GetCalledN returns true if FakeProvider.Get was called at least n times

func (*FakeProvider) GetCalledOnce

func (f *FakeProvider) GetCalledOnce() bool

GetCalledOnce returns true if FakeProvider.Get was called exactly once

func (*FakeProvider) GetCalledOnceWith

func (_f8 *FakeProvider) GetCalledOnceWith(ident1 string) bool

GetCalledOnceWith returns true if FakeProvider.Get was called exactly once with the given values

func (*FakeProvider) GetCalledWith

func (_f6 *FakeProvider) GetCalledWith(ident1 string) (found bool)

GetCalledWith returns true if FakeProvider.Get was called with the given values

func (*FakeProvider) GetInt

func (_f11 *FakeProvider) GetInt(ident1 string) (ident2 int, ident3 merry.Error)

func (*FakeProvider) GetIntCalled

func (f *FakeProvider) GetIntCalled() bool

GetIntCalled returns true if FakeProvider.GetInt was called

func (*FakeProvider) GetIntCalledN

func (f *FakeProvider) GetIntCalledN(n int) bool

GetIntCalledN returns true if FakeProvider.GetInt was called at least n times

func (*FakeProvider) GetIntCalledOnce

func (f *FakeProvider) GetIntCalledOnce() bool

GetIntCalledOnce returns true if FakeProvider.GetInt was called exactly once

func (*FakeProvider) GetIntCalledOnceWith

func (_f18 *FakeProvider) GetIntCalledOnceWith(ident1 string) bool

GetIntCalledOnceWith returns true if FakeProvider.GetInt was called exactly once with the given values

func (*FakeProvider) GetIntCalledWith

func (_f16 *FakeProvider) GetIntCalledWith(ident1 string) (found bool)

GetIntCalledWith returns true if FakeProvider.GetInt was called with the given values

func (*FakeProvider) GetIntNotCalled

func (f *FakeProvider) GetIntNotCalled() bool

GetIntNotCalled returns true if FakeProvider.GetInt was not called

func (*FakeProvider) GetIntResultsForCall

func (_f20 *FakeProvider) GetIntResultsForCall(ident1 string) (ident2 int, ident3 merry.Error, found bool)

GetIntResultsForCall returns the result values for the first call to FakeProvider.GetInt with the given values

func (*FakeProvider) GetNotCalled

func (f *FakeProvider) GetNotCalled() bool

GetNotCalled returns true if FakeProvider.Get was not called

func (*FakeProvider) GetResultsForCall

func (_f10 *FakeProvider) GetResultsForCall(ident1 string) (ident2 string, ident3 merry.Error, found bool)

GetResultsForCall returns the result values for the first call to FakeProvider.Get with the given values

func (*FakeProvider) Monitor

func (_f31 *FakeProvider) Monitor(ident1 string, ident2 chan<- Value)

func (*FakeProvider) MonitorCalled

func (f *FakeProvider) MonitorCalled() bool

MonitorCalled returns true if FakeProvider.Monitor was called

func (*FakeProvider) MonitorCalledN

func (f *FakeProvider) MonitorCalledN(n int) bool

MonitorCalledN returns true if FakeProvider.Monitor was called at least n times

func (*FakeProvider) MonitorCalledOnce

func (f *FakeProvider) MonitorCalledOnce() bool

MonitorCalledOnce returns true if FakeProvider.Monitor was called exactly once

func (*FakeProvider) MonitorCalledOnceWith

func (_f34 *FakeProvider) MonitorCalledOnceWith(ident1 string, ident2 chan<- Value) bool

MonitorCalledOnceWith returns true if FakeProvider.Monitor was called exactly once with the given values

func (*FakeProvider) MonitorCalledWith

func (_f32 *FakeProvider) MonitorCalledWith(ident1 string, ident2 chan<- Value) (found bool)

MonitorCalledWith returns true if FakeProvider.Monitor was called with the given values

func (*FakeProvider) MonitorNotCalled

func (f *FakeProvider) MonitorNotCalled() bool

MonitorNotCalled returns true if FakeProvider.Monitor was not called

func (*FakeProvider) Reset

func (f *FakeProvider) Reset()

func (*FakeProvider) SetGetBoolInvocation

func (_f23 *FakeProvider) SetGetBoolInvocation(calls_f24 []*ProviderGetBoolInvocation, fallback_f25 func() (bool, merry.Error))

SetGetBoolInvocation configures Provider.GetBool to return the given results when called with the given parameters If no match is found for an invocation the result(s) of the fallback function are returned

func (*FakeProvider) SetGetBoolStub

func (_f22 *FakeProvider) SetGetBoolStub(ident2 bool, ident3 merry.Error)

SetGetBoolStub configures Provider.GetBool to always return the given values

func (*FakeProvider) SetGetIntInvocation

func (_f13 *FakeProvider) SetGetIntInvocation(calls_f14 []*ProviderGetIntInvocation, fallback_f15 func() (int, merry.Error))

SetGetIntInvocation configures Provider.GetInt to return the given results when called with the given parameters If no match is found for an invocation the result(s) of the fallback function are returned

func (*FakeProvider) SetGetIntStub

func (_f12 *FakeProvider) SetGetIntStub(ident2 int, ident3 merry.Error)

SetGetIntStub configures Provider.GetInt to always return the given values

func (*FakeProvider) SetGetInvocation

func (_f3 *FakeProvider) SetGetInvocation(calls_f4 []*ProviderGetInvocation, fallback_f5 func() (string, merry.Error))

SetGetInvocation configures Provider.Get to return the given results when called with the given parameters If no match is found for an invocation the result(s) of the fallback function are returned

func (*FakeProvider) SetGetStub

func (_f2 *FakeProvider) SetGetStub(ident2 string, ident3 merry.Error)

SetGetStub configures Provider.Get to always return the given values

type MultiProvider

type MultiProvider []Provider

func (MultiProvider) Get

func (p MultiProvider) Get(name string) (string, merry.Error)

func (MultiProvider) GetBool

func (p MultiProvider) GetBool(name string) (bool, merry.Error)

func (MultiProvider) GetInt

func (p MultiProvider) GetInt(name string) (int, merry.Error)

func (MultiProvider) Monitor

func (p MultiProvider) Monitor(name string, v chan<- Value)

type Provider

type Provider interface {
	Get(string) (string, merry.Error)
	GetInt(string) (int, merry.Error)
	GetBool(string) (bool, merry.Error)
	Monitor(string, chan<- Value)
}

func NewSystem

func NewSystem() Provider

type ProviderGetBoolInvocation

type ProviderGetBoolInvocation struct {
	Parameters struct {
		Ident1 string
	}
	Results struct {
		Ident2 bool
		Ident3 merry.Error
	}
}

ProviderGetBoolInvocation represents a single call of FakeProvider.GetBool

func NewProviderGetBoolInvocation

func NewProviderGetBoolInvocation(ident1 string, ident2 bool, ident3 merry.Error) *ProviderGetBoolInvocation

NewProviderGetBoolInvocation creates a new instance of ProviderGetBoolInvocation

type ProviderGetIntInvocation

type ProviderGetIntInvocation struct {
	Parameters struct {
		Ident1 string
	}
	Results struct {
		Ident2 int
		Ident3 merry.Error
	}
}

ProviderGetIntInvocation represents a single call of FakeProvider.GetInt

func NewProviderGetIntInvocation

func NewProviderGetIntInvocation(ident1 string, ident2 int, ident3 merry.Error) *ProviderGetIntInvocation

NewProviderGetIntInvocation creates a new instance of ProviderGetIntInvocation

type ProviderGetInvocation

type ProviderGetInvocation struct {
	Parameters struct {
		Ident1 string
	}
	Results struct {
		Ident2 string
		Ident3 merry.Error
	}
}

ProviderGetInvocation represents a single call of FakeProvider.Get

func NewProviderGetInvocation

func NewProviderGetInvocation(ident1 string, ident2 string, ident3 merry.Error) *ProviderGetInvocation

NewProviderGetInvocation creates a new instance of ProviderGetInvocation

type ProviderMonitorInvocation

type ProviderMonitorInvocation struct {
	Parameters struct {
		Ident1 string
		Ident2 chan<- Value
	}
}

ProviderMonitorInvocation represents a single call of FakeProvider.Monitor

type ProviderTestingT

type ProviderTestingT interface {
	Error(...interface{})
	Errorf(string, ...interface{})
	Fatal(...interface{})
	Helper()
}

ProviderTestingT represents the methods of "testing".T used by charlatan Fakes. It avoids importing the testing package.

type Value

type Value struct {
	Name  string
	Value string
}

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier