Documentation ¶
Overview ¶
Package config contains the structures, flags, and parsing of the cbtest configuration. Note that configuration is optional, and can be passed either using a config file or command line flags (with the latter taking precedence over the former).
Configuration file ¶
A minimal configuration file looks like follows:
{ "platformUrl": "https://INSTANCE.clearblade.com", "messagingUrl": "INSTANCE.clearblade.com:1883", "registrationKey": "some-registration-key", "systemKey": "abc123abc123abc123abc123abc123", "systemSecret": "ABC123ABC123ABC123ABC123ABC123", "developer": { "email": "some-email@email.com", "password": "some-password" } }
Flags ¶
Since cbtest integrates with go test, flags can be specified as follows:
go test -v <PATH-TO-TEST> -args -cbtest.config <PATH-TO-CONFIG> [-cbtest.*]
Index ¶
- func ConfigOut() string
- func ConfigPath() string
- func DeveloperEmail() string
- func DeveloperPassword() string
- func DeviceActiveKey() string
- func DeviceName() string
- func FlagFound(name string) bool
- func HasConfig() bool
- func HasConfigOut() bool
- func MessagingURL() string
- func PlatformURL() string
- func RegistrationKey() string
- func SaveConfig(t cbtest.T, c *Config) (string, error)
- func ShouldImportRows() bool
- func ShouldImportUsers() bool
- func SystemKey() string
- func SystemSecret() string
- func UserEmail() string
- func UserPassword() string
- func WriteConfig(w io.Writer, c *Config) error
- func WriteConfigToPath(path string, c *Config) error
- type Config
- type Developer
- type Device
- type Import
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigOut ¶
func ConfigOut() string
ConfigOut returns the value given to the `-cbtest.config-out` flag.
func ConfigPath ¶
func ConfigPath() string
ConfigPath returns the value given to the `-cbtest.config` flag.
func DeveloperEmail ¶
func DeveloperEmail() string
DeveloperEmail returns the value given to the `-cbtest.dev-email` flag.
func DeveloperPassword ¶
func DeveloperPassword() string
DeveloperPassword returns the value given to the `-cbtest.dev-password` flag.
func DeviceActiveKey ¶
func DeviceActiveKey() string
DeviceActiveKey returns the value given to the `-cbtest.device-active-key` flag.
func DeviceName ¶
func DeviceName() string
DeviceName returns the value given to the `-cbtest.device-name` flag.
func HasConfigOut ¶
func HasConfigOut() bool
HasConfigOut returns true if the user passed the `-cbtest.config-out` flag.
func MessagingURL ¶
func MessagingURL() string
MessagingURL returns the value given to the `-cbtest.messaging-url` flag.
func PlatformURL ¶
func PlatformURL() string
PlatformURL returns the value given to the `-cbtest.platform-url` flag.
func RegistrationKey ¶
func RegistrationKey() string
RegistrationKey returns the value given to the `-cbtest.registration-key` flag.
func SaveConfig ¶
SaveConfig saves the config to disk. It uses either (1) the config Out field if provided, or (2) a default path constructed from the given test object. Returns the output path and an error (if any).
func ShouldImportRows ¶
func ShouldImportRows() bool
ShouldImportRows returns the value given to the `-cbtest.import-rows` flag.
func ShouldImportUsers ¶
func ShouldImportUsers() bool
ShouldImportUsers returns the value given to the `-cbtest.import-users` flag.
func SystemKey ¶
func SystemKey() string
SystemKey returns the value given to the `-cbtest.system-key` flag.
func SystemSecret ¶
func SystemSecret() string
SystemSecret returns the value given to the `-cbtest.system-secret` flag.
func UserEmail ¶
func UserEmail() string
UserEmail returns the value given to the `-cbtest.user-email` flag.
func UserPassword ¶
func UserPassword() string
UserPassword returns the value given to the `-cbtest.user-password` flag.
func WriteConfig ¶
WriteConfig writes the config to the given writer.
func WriteConfigToPath ¶
WriteConfigToPath writes the config to the given path.
Types ¶
type Config ¶
type Config struct { PlatformURL string `json:"platformUrl" mapstructure:"platformUrl"` MessagingURL string `json:"messagingUrl" mapstructure:"messagingUrl"` RegistrationKey string `json:"registrationKey,omitempty" mapstructure:"registrationKey"` SystemKey string `json:"systemKey,omitempty" mapstructure:"systemKey"` SystemSecret string `json:"systemSecret,omitempty" mapstructure:"systemSecret"` Developer *Developer `json:"developer,omitempty" mapstructure:"developer"` User *User `json:"user,omitempty" mapstructre:"user"` Device *Device `json:"device,omitempty" mapstructure:"device"` Import *Import `json:"import,omitempty" mapstructure:"import"` Out string `json:"-" mapstructure:"-"` }
Config contains information about the system that is gonna be used for testing.
func GetDefaultConfig ¶
func GetDefaultConfig() *Config
GetDefaultConfig returns a new *Config instance with default values.
func ObtainConfig ¶
ObtainConfig returns the config that is gonna be used by cbtest. It uses either (1) default config, or (2) config read from the config path flag. Final values in the config are overridden by those provided in the flags.
func ReadConfig ¶
ReadConfig reads the config from the given reader.
func ReadConfigFromPath ¶
ReadConfigFromPath reads the config from the given path.
func (*Config) HasDeveloper ¶
HasDeveloper returns true if the given config has developer information.
func (*Config) ShouldSave ¶
ShouldSave returns true if the out field of config is not empty (meaning the user to save the config to the specified path).
type Developer ¶
type Developer struct { Email string `json:"email" mapstructure:"email"` Password string `json:"password" mapstructure:"password"` }
Developer contains the developer credentials that must be provided if using an existing system.
type Device ¶
type Device struct { Name string `json:"name" mapstructure:"name"` ActiveKey string `json:"activeKey" mapstructure:"activeKey"` }
Device contains the credentials for a device in the system.