Documentation ¶
Index ¶
- Constants
- func EnsureGotErrors(t *testing.T)
- func EnsureGotWarnings(t *testing.T)
- func EnsureNoErrorsOrWarnings(t *testing.T)
- func FormatMQTTMessage(message wbgo.MQTTMessage) string
- func RunSuites(t *testing.T, suites ...suite.TestingSuite)
- func SetupTempDir(t *testing.T) (string, func())
- func SetupTestLogging(t *testing.T)
- func WaitFor(t *testing.T, pred func() bool)
- func WaitForErrors(t *testing.T)
- func WaitForWarnings(t *testing.T)
- type DataFileFixture
- func (f *DataFileFixture) CopyDataFileToTempDir(sourceName, targetName string) (targetPath string)
- func (f *DataFileFixture) CopyDataFilesToTempDir(names ...string)
- func (f *DataFileFixture) CopyModifiedDataFileToTempDir(sourceName, targetName string, edit func(string) string) (targetPath string)
- func (f *DataFileFixture) DataFilePath(dataFile string) string
- func (f *DataFileFixture) DataFileTempDir() string
- func (f *DataFileFixture) ReadSourceDataFile(sourceName string) string
- func (f *DataFileFixture) RmFile(filename string)
- func (f *DataFileFixture) SourceDir() string
- func (f *DataFileFixture) TearDownDataFiles()
- func (f *DataFileFixture) WriteDataFile(filename, content string) string
- type FakeDev
- type FakeDevice
- type FakeExtDevice
- type FakeLocalDevice
- type FakeMQTTBroker
- func (broker *FakeMQTTBroker) MakeClient(id string) (client *FakeMQTTClient)
- func (broker *FakeMQTTBroker) Publish(origin string, message wbgo.MQTTMessage)
- func (broker *FakeMQTTBroker) SetReady()
- func (broker *FakeMQTTBroker) SetWaitForRetained(waitForRetained bool)
- func (broker *FakeMQTTBroker) Subscribe(client *FakeMQTTClient, topic string)
- func (broker *FakeMQTTBroker) Unsubscribe(client *FakeMQTTClient, topic string)
- type FakeMQTTClient
- func (client *FakeMQTTClient) Publish(message wbgo.MQTTMessage)
- func (client *FakeMQTTClient) PublishSync(message wbgo.MQTTMessage)
- func (client *FakeMQTTClient) Start()
- func (client *FakeMQTTClient) Stop()
- func (client *FakeMQTTClient) Subscribe(callback wbgo.MQTTMessageHandler, topics ...string)
- func (client *FakeMQTTClient) Unsubscribe(topics ...string)
- func (client *FakeMQTTClient) WaitForReady() <-chan struct{}
- type FakeMQTTFixture
- type FakeModel
- func (model *FakeModel) AddExternalDevice(name string) (wbgo.ExternalDeviceModel, error)
- func (model *FakeModel) GetDevice(name string) FakeDev
- func (model *FakeModel) HasDevice(name string) bool
- func (model *FakeModel) MakeLocalDevice(name string, title string, paramTypes map[string]string) (dev *FakeLocalDevice)
- func (model *FakeModel) MakeLocalVirtualDevice(name string, title string, paramTypes map[string]string) (dev *FakeLocalDevice)
- func (model *FakeModel) Poll()
- func (model *FakeModel) Start() error
- type FakeTimerFixture
- func (fixture *FakeTimerFixture) AdvanceTime(d time.Duration) time.Time
- func (fixture *FakeTimerFixture) ClearTimers()
- func (fixture *FakeTimerFixture) CurrentTime() time.Time
- func (fixture *FakeTimerFixture) FireTimer(id uint64, ts time.Time)
- func (fixture *FakeTimerFixture) NewFakeTicker(d time.Duration) wbgo.Timer
- func (fixture *FakeTimerFixture) NewFakeTimer(d time.Duration) wbgo.Timer
- func (fixture *FakeTimerFixture) NewFakeTimerOrTicker(id uint64, d time.Duration, periodic bool) wbgo.Timer
- type Fixture
- type RecMatcher
- func JSONRecMatcher(value objx.Map, itemRx string) *RecMatcher
- func NewRecMatcher(text string, fn RecMatcherFunc) *RecMatcher
- func RegexpCaptureMatcher(itemRx string, handler RegexpCaptureHandler) *RecMatcher
- func RegexpCaptureMatcherWithCustomText(itemRx string, text string, handler RegexpCaptureHandler) *RecMatcher
- type RecMatcherFunc
- type Recorder
- func (rec *Recorder) Rec(format string, args ...interface{})
- func (rec *Recorder) SetEmptyWaitTime(duration time.Duration)
- func (rec *Recorder) SkipTill(logItem string)
- func (rec *Recorder) Verify(logs ...interface{})
- func (rec *Recorder) VerifyEmpty()
- func (rec *Recorder) VerifyUnordered(logs ...interface{})
- type RegexpCaptureHandler
- type RpcFixture
- type SubscriptionList
- type SubscriptionMap
- type Suite
- func (suite *Suite) Ck(msg string, err error)
- func (suite *Suite) EnsureGotErrors()
- func (suite *Suite) EnsureGotWarnings()
- func (suite *Suite) EnsureNoErrorsOrWarnings()
- func (suite *Suite) SetupTest()
- func (suite *Suite) TearDownTest()
- func (suite *Suite) WaitFor(pred func() bool)
- func (suite *Suite) WaitForErrors()
- func (suite *Suite) WaitForWarnings()
- type TestLog
Constants ¶
const ( WAIT_INTERVAL_MS = 10 WAIT_COUNT = 300 REC_EMPTY_WAIT_TIME_MS = 50 REC_SKIP_TIME_MS = 3000 REC_ITEM_TIMEOUT_MS = 5000 )
const (
SAMPLE_CLIENT_ID = "11111111"
)
Variables ¶
This section is empty.
Functions ¶
func EnsureGotErrors ¶
func EnsureGotWarnings ¶
func FormatMQTTMessage ¶
func FormatMQTTMessage(message wbgo.MQTTMessage) string
func RunSuites ¶
func RunSuites(t *testing.T, suites ...suite.TestingSuite)
RunSuites runs the specified test suites
func SetupTempDir ¶
SetupTempDir creates a temporary directory to be used in tests and makes it the current directory. In case of an error, makes the test fail. Returns the path to the temporary directory and cleanup function that removes the directory and changes back to the directory that was current before SetupTempDir was called.
func SetupTestLogging ¶
SetupTestLogging sets up the logging output in such way that it's only shown if the current test fails.
func WaitFor ¶
WaitFor waits for the function specified by pred to return true. The test fails if it takes too long.
func WaitForErrors ¶
func WaitForWarnings ¶
Types ¶
type DataFileFixture ¶
type DataFileFixture struct { *Fixture // contains filtered or unexported fields }
func NewDataFileFixture ¶
func NewDataFileFixture(t *testing.T) (f *DataFileFixture)
func (*DataFileFixture) CopyDataFileToTempDir ¶
func (f *DataFileFixture) CopyDataFileToTempDir(sourceName, targetName string) (targetPath string)
func (*DataFileFixture) CopyDataFilesToTempDir ¶
func (f *DataFileFixture) CopyDataFilesToTempDir(names ...string)
func (*DataFileFixture) CopyModifiedDataFileToTempDir ¶
func (f *DataFileFixture) CopyModifiedDataFileToTempDir(sourceName, targetName string, edit func(string) string) (targetPath string)
func (*DataFileFixture) DataFilePath ¶
func (f *DataFileFixture) DataFilePath(dataFile string) string
func (*DataFileFixture) DataFileTempDir ¶
func (f *DataFileFixture) DataFileTempDir() string
func (*DataFileFixture) ReadSourceDataFile ¶
func (f *DataFileFixture) ReadSourceDataFile(sourceName string) string
func (*DataFileFixture) RmFile ¶
func (f *DataFileFixture) RmFile(filename string)
func (*DataFileFixture) SourceDir ¶
func (f *DataFileFixture) SourceDir() string
func (*DataFileFixture) TearDownDataFiles ¶
func (f *DataFileFixture) TearDownDataFiles()
func (*DataFileFixture) WriteDataFile ¶
func (f *DataFileFixture) WriteDataFile(filename, content string) string
type FakeDevice ¶
type FakeDevice struct { wbgo.DeviceBase // contains filtered or unexported fields }
func (*FakeDevice) AcceptValue ¶
func (dev *FakeDevice) AcceptValue(name, value string)
func (*FakeDevice) GetType ¶
func (dev *FakeDevice) GetType(name string) string
func (*FakeDevice) GetValue ¶
func (dev *FakeDevice) GetValue(name string) string
func (*FakeDevice) ReceiveValue ¶
func (dev *FakeDevice) ReceiveValue(name, value string)
type FakeExtDevice ¶
type FakeExtDevice struct {
FakeDevice
}
func (*FakeExtDevice) AcceptControlRange ¶
func (dev *FakeExtDevice) AcceptControlRange(name string, max float64)
func (*FakeExtDevice) AcceptControlType ¶
func (dev *FakeExtDevice) AcceptControlType(name, controlType string)
type FakeLocalDevice ¶
type FakeLocalDevice struct { FakeDevice // contains filtered or unexported fields }
func (*FakeLocalDevice) AcceptOnValue ¶
func (dev *FakeLocalDevice) AcceptOnValue(name, value string) bool
func (*FakeLocalDevice) IsVirtual ¶
func (dev *FakeLocalDevice) IsVirtual() bool
func (*FakeLocalDevice) QueryParams ¶
func (dev *FakeLocalDevice) QueryParams()
type FakeMQTTBroker ¶
func NewFakeMQTTBroker ¶
func NewFakeMQTTBroker(t *testing.T, rec *Recorder) (broker *FakeMQTTBroker)
func (*FakeMQTTBroker) MakeClient ¶
func (broker *FakeMQTTBroker) MakeClient(id string) (client *FakeMQTTClient)
func (*FakeMQTTBroker) Publish ¶
func (broker *FakeMQTTBroker) Publish(origin string, message wbgo.MQTTMessage)
func (*FakeMQTTBroker) SetReady ¶
func (broker *FakeMQTTBroker) SetReady()
func (*FakeMQTTBroker) SetWaitForRetained ¶
func (broker *FakeMQTTBroker) SetWaitForRetained(waitForRetained bool)
func (*FakeMQTTBroker) Subscribe ¶
func (broker *FakeMQTTBroker) Subscribe(client *FakeMQTTClient, topic string)
func (*FakeMQTTBroker) Unsubscribe ¶
func (broker *FakeMQTTBroker) Unsubscribe(client *FakeMQTTClient, topic string)
type FakeMQTTClient ¶
func (*FakeMQTTClient) Publish ¶
func (client *FakeMQTTClient) Publish(message wbgo.MQTTMessage)
func (*FakeMQTTClient) PublishSync ¶
func (client *FakeMQTTClient) PublishSync(message wbgo.MQTTMessage)
func (*FakeMQTTClient) Start ¶
func (client *FakeMQTTClient) Start()
func (*FakeMQTTClient) Stop ¶
func (client *FakeMQTTClient) Stop()
func (*FakeMQTTClient) Subscribe ¶
func (client *FakeMQTTClient) Subscribe(callback wbgo.MQTTMessageHandler, topics ...string)
func (*FakeMQTTClient) Unsubscribe ¶
func (client *FakeMQTTClient) Unsubscribe(topics ...string)
func (*FakeMQTTClient) WaitForReady ¶
func (client *FakeMQTTClient) WaitForReady() <-chan struct{}
type FakeMQTTFixture ¶
type FakeMQTTFixture struct { *Recorder Broker *FakeMQTTBroker }
func NewFakeMQTTFixture ¶
func NewFakeMQTTFixture(t *testing.T) *FakeMQTTFixture
type FakeModel ¶
func NewFakeModel ¶
func (*FakeModel) AddExternalDevice ¶
func (model *FakeModel) AddExternalDevice(name string) (wbgo.ExternalDeviceModel, error)
func (*FakeModel) MakeLocalDevice ¶
func (*FakeModel) MakeLocalVirtualDevice ¶
type FakeTimerFixture ¶
type FakeTimerFixture struct { *Fixture // contains filtered or unexported fields }
func NewFakeTimerFixture ¶
func NewFakeTimerFixture(t *testing.T, rec *Recorder) *FakeTimerFixture
TBD: use Setup instead
func (*FakeTimerFixture) AdvanceTime ¶
func (fixture *FakeTimerFixture) AdvanceTime(d time.Duration) time.Time
func (*FakeTimerFixture) ClearTimers ¶
func (fixture *FakeTimerFixture) ClearTimers()
func (*FakeTimerFixture) CurrentTime ¶
func (fixture *FakeTimerFixture) CurrentTime() time.Time
func (*FakeTimerFixture) FireTimer ¶
func (fixture *FakeTimerFixture) FireTimer(id uint64, ts time.Time)
func (*FakeTimerFixture) NewFakeTicker ¶
func (fixture *FakeTimerFixture) NewFakeTicker(d time.Duration) wbgo.Timer
func (*FakeTimerFixture) NewFakeTimer ¶
func (fixture *FakeTimerFixture) NewFakeTimer(d time.Duration) wbgo.Timer
func (*FakeTimerFixture) NewFakeTimerOrTicker ¶
type RecMatcher ¶
type RecMatcher struct {
// contains filtered or unexported fields
}
func JSONRecMatcher ¶
func JSONRecMatcher(value objx.Map, itemRx string) *RecMatcher
JSONRecMatcher returns a matcher that matches a first group captured by regular expression rx against JSON value. If rx has no groups, the whole text matched by rx is used
func NewRecMatcher ¶
func NewRecMatcher(text string, fn RecMatcherFunc) *RecMatcher
func RegexpCaptureMatcher ¶
func RegexpCaptureMatcher(itemRx string, handler RegexpCaptureHandler) *RecMatcher
RegexpCaptureMatcher is the same as RegexpCaptureMatcherWithCustomText but uses itemRx as mismatch text
func RegexpCaptureMatcherWithCustomText ¶
func RegexpCaptureMatcherWithCustomText(itemRx string, text string, handler RegexpCaptureHandler) *RecMatcher
RegexpCaptureMatcherWithCustomText returns a matcher that matches the specified regexp against the item being verified, then invokes handler with submatches slice as an argument. Succeeds only in case handler returns true. The speicified text is used in mismatch logs.
type RecMatcherFunc ¶
type Recorder ¶
type Recorder struct { *Fixture // contains filtered or unexported fields }
func NewRecorder ¶
func (*Recorder) SetEmptyWaitTime ¶
func (*Recorder) VerifyEmpty ¶
func (rec *Recorder) VerifyEmpty()
func (*Recorder) VerifyUnordered ¶
func (rec *Recorder) VerifyUnordered(logs ...interface{})
type RegexpCaptureHandler ¶
type RpcFixture ¶
type RpcFixture struct { *FakeMQTTFixture // contains filtered or unexported fields }
func NewRpcFixture ¶
func NewRpcFixture(t *testing.T, app, service, clientName string, rcvr interface{}, methods ...string) (f *RpcFixture)
func (*RpcFixture) TearDownRPC ¶
func (f *RpcFixture) TearDownRPC()
func (*RpcFixture) VerifyRpc ¶
func (f *RpcFixture) VerifyRpc(subtopic string, params objx.Map, expectedResult interface{})
func (*RpcFixture) VerifyRpcError ¶
type SubscriptionList ¶
type SubscriptionList []*FakeMQTTClient
type SubscriptionMap ¶
type SubscriptionMap map[string]SubscriptionList
type Suite ¶
func (*Suite) EnsureGotErrors ¶
func (suite *Suite) EnsureGotErrors()
func (*Suite) EnsureGotWarnings ¶
func (suite *Suite) EnsureGotWarnings()
func (*Suite) EnsureNoErrorsOrWarnings ¶
func (suite *Suite) EnsureNoErrorsOrWarnings()
func (*Suite) TearDownTest ¶
func (suite *Suite) TearDownTest()
func (*Suite) WaitForErrors ¶
func (suite *Suite) WaitForErrors()
func (*Suite) WaitForWarnings ¶
func (suite *Suite) WaitForWarnings()
type TestLog ¶
TestLog makes it possible to use log module with testing's logging functions, so that the logging output is only shown when the test fails. Note that a part at the end of output that is not newline-terminated is not displayed.
func NewTestLog ¶
func (*TestLog) VerifyPristine ¶
func (*TestLog) VerifyUsed ¶
func (*TestLog) WaitForMessages ¶
func (tl *TestLog) WaitForMessages()