test

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const LOG_FORMAT = "%{color}%{time:2006/01/02 15:04:05 -07:00 MST} [%{level:.6s}] %{shortfile} : %{color:reset}%{message}"

Variables

This section is empty.

Functions

func AddOrgThing

func AddOrgThing(t *testing.T, db *mongo.Database, orgId primitive.ObjectID, thingName string)

func AddOrgUser

func AddOrgUser(t *testing.T, db *mongo.Database, orgId, userId primitive.ObjectID)

func Assert

func Assert(tb testing.TB, condition bool, msg string, v ...interface{})

assert fails the test if the condition is false.

func CleanDb

func CleanDb(t *testing.T, db *mongo.Database)

func Contains added in v1.0.6

func Contains(t *testing.T, str, pattern string)

func CreateDevice

func CreateDevice(t *testing.T, db *mongo.Database, name string) primitive.ObjectID

func CreateOrg

func CreateOrg(t *testing.T, db *mongo.Database, name string) primitive.ObjectID

func CreateSwitch

func CreateSwitch(t *testing.T, db *mongo.Database, name string) primitive.ObjectID

func CreateThing

func CreateThing(t *testing.T, db *mongo.Database, name string) primitive.ObjectID

func CreateUser

func CreateUser(t *testing.T, db *mongo.Database, email, password string) primitive.ObjectID

func Equals

func Equals(tb testing.TB, exp, act interface{})

equals fails the test if exp is not equal to act.

func GetConfig

func GetConfig() *config.Parameters

func GetDb

func GetDb(t *testing.T) *mongo.Database

func GetLogger

func GetLogger(t *testing.T) *logging.Logger

func GetOrgs

func GetOrgs(t *testing.T, logger *logging.Logger, db *mongo.Database) *piot.Orgs

func GetPiotDevices

func GetPiotDevices(t *testing.T, logger *logging.Logger, things *piot.Things, mqtt piot.IMqtt) *piot.PiotDevices

func GetThings

func GetThings(t *testing.T, logger *logging.Logger, db *mongo.Database) *piot.Things

func GetUsers

func GetUsers(t *testing.T, logger *logging.Logger, db *mongo.Database) *piot.Users

func Ok

func Ok(tb testing.TB, err error)

ok fails the test if an err is not nil.

func SetSensorMeasurementTopic

func SetSensorMeasurementTopic(t *testing.T, db *mongo.Database, thingId primitive.ObjectID, topic string)

func SetSwitchStateTopic

func SetSwitchStateTopic(t *testing.T, db *mongo.Database, thingId primitive.ObjectID, topic, on, off string)

func SetThingLocationParams

func SetThingLocationParams(
	t *testing.T,
	db *mongo.Database,
	thingId primitive.ObjectID,
	topic string,
	lat_value string,
	lng_value string,
	sat_value string,
	ts_value string,
	tracking bool)

func SetThingTelemetryTopic

func SetThingTelemetryTopic(t *testing.T, db *mongo.Database, thingId primitive.ObjectID, topic string)

Types

type HttpClientMock

type HttpClientMock struct {
	Log   *logging.Logger
	Calls []httpClientMockCall
}

implements IMqtt interface

func GetHttpClient

func GetHttpClient(t *testing.T, logger *logging.Logger) *HttpClientMock

func (*HttpClientMock) PostString

func (c *HttpClientMock) PostString(url, body string, username *string, password *string)

type InfluxDbMock

type InfluxDbMock struct {
	Log   *logging.Logger
	Calls []influxDbMockCall
}

implements IMqtt interface

func GetInfluxDb

func GetInfluxDb(t *testing.T, logger *logging.Logger) *InfluxDbMock

func (*InfluxDbMock) PostLocation added in v1.0.2

func (db *InfluxDbMock) PostLocation(thing *model.Thing, lat, lng float64, sat, ts int32)

func (*InfluxDbMock) PostMeasurement

func (db *InfluxDbMock) PostMeasurement(thing *model.Thing, value string)

func (*InfluxDbMock) PostSwitchState

func (db *InfluxDbMock) PostSwitchState(thing *model.Thing, value string)

type MqttMock

type MqttMock struct {
	Log   *logging.Logger
	Calls []call
}

implements IMqtt interface

func GetMqtt

func GetMqtt(t *testing.T, logger *logging.Logger) *MqttMock

func (*MqttMock) Connect

func (t *MqttMock) Connect(subscribe bool) error

func (*MqttMock) Disconnect

func (t *MqttMock) Disconnect() error

func (*MqttMock) ProcessMessage

func (t *MqttMock) ProcessMessage(topic, payload string)

func (*MqttMock) PushThingData

func (t *MqttMock) PushThingData(thing *model.Thing, topic, value string) error

func (*MqttMock) SetClient

func (t *MqttMock) SetClient(id string)

func (*MqttMock) SetPassword

func (t *MqttMock) SetPassword(password string)

func (*MqttMock) SetUsername

func (t *MqttMock) SetUsername(username string)

type MysqlDbMock

type MysqlDbMock struct {
	Log   *logging.Logger
	Calls []mysqlDbMockCall
}

implements IMysqlDb interface

func GetMysqlDb

func GetMysqlDb(t *testing.T, logger *logging.Logger) *MysqlDbMock

func (*MysqlDbMock) Close

func (db *MysqlDbMock) Close()

func (*MysqlDbMock) Open

func (db *MysqlDbMock) Open() error

func (*MysqlDbMock) StoreMeasurement

func (db *MysqlDbMock) StoreMeasurement(thing *model.Thing, value string)

func (*MysqlDbMock) StoreSwitchState

func (db *MysqlDbMock) StoreSwitchState(thing *model.Thing, value string)

Jump to

Keyboard shortcuts

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