testutil

package
v0.1.0-M4 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0, EPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPTest

type HTTPTest struct {
	Subscription *SubscriptionDetails
	// contains filtered or unexported fields
}

HTTPTest is a structure used for automatic setup and creation of http related tests.

func NewHTTPTest

func NewHTTPTest() (HTTPTest, error)

NewHTTPTest returns a new HTTPTest.

func (*HTTPTest) NewThingsRequest

func (t *HTTPTest) NewThingsRequest(deviceID string) *ThingsHTTPRequest

NewThingsRequest returns a new ThingsHTTPRequest.

type MessageClient

type MessageClient struct {
	Subscription *SubscriptionDetails
	MessagesCh   <-chan *message.Message
	Pub          message.Publisher
	Sub          message.Subscriber
	Connection   *connector.MQTTConnection
	// contains filtered or unexported fields
}

MessageClient contains the testing messaging related data.

func NewMessageClient

func NewMessageClient(t *testing.T) (*MessageClient, error)

NewMessageClient returns a new MessageClient with an initialized testutil.SubscriptionDetails, local MQTT connection and publisher.

func (*MessageClient) Publish

func (c *MessageClient) Publish(pubTopic string, data []byte) error

Publish creates a new message.Message and publishes it using the client publisher.

func (*MessageClient) WithSub

func (c *MessageClient) WithSub(thingNames ...string) (*MessageClient, error)

WithSub initializes the client subscriber and message channel. The thing names are used to build the things` model.NamespacedID and subscription topic.

type SubscriptionDetails

type SubscriptionDetails struct {
	GrantType         string `json:"grantType,omitempty"`
	ClientID          string `json:"clientId,omitempty"`
	ClientSecret      string `json:"clientSecret,omitempty"`
	ClientScopeThings string `json:"clientScopeThings,omitempty"`
	Namespace         string `json:"namespace,omitempty"`
	DeviceName        string `json:"deviceName,omitempty"`
	TenantID          string `json:"tenantId,omitempty"`
}

SubscriptionDetails is used in multiple test files.

type ThingsHTTPRequest

type ThingsHTTPRequest struct {
	// contains filtered or unexported fields
}

ThingsHTTPRequest represents an HTTP request used to retrieve or manipulate remote thing data.

func (*ThingsHTTPRequest) Delete

func (r *ThingsHTTPRequest) Delete() *ThingsHTTPRequest

Delete sets the value of the method of r to "DELETE".

func (*ThingsHTTPRequest) Execute

func (r *ThingsHTTPRequest) Execute() ([]byte, error)

Execute creates a new http.Request using the data from r and executes it using a http.Client. Returns the body of the received http.Response.

func (*ThingsHTTPRequest) Feature

func (r *ThingsHTTPRequest) Feature(featureID string) *ThingsHTTPRequest

Feature sets the relative path of r using featureID to refer to the specified feature.

func (*ThingsHTTPRequest) Get

Get sets the value of the method of r to "GET".

func (*ThingsHTTPRequest) Put

func (r *ThingsHTTPRequest) Put(data interface{}) *ThingsHTTPRequest

Put sets the value of the method of r to "PUT".

Jump to

Keyboard shortcuts

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