Пример #1
0
func TestRequireEndpointUsed(t *testing.T) {
	svc := iotdataplane.New(&aws.Config{
		Region:                 aws.String("mock-region"),
		DisableParamValidation: aws.Bool(true),
		Endpoint:               aws.String("https://endpoint"),
	})
	req, _ := svc.GetThingShadowRequest(nil)
	err := req.Build()

	assert.Equal(t, "https://endpoint", svc.Endpoint)
	assert.NoError(t, err)
}
Пример #2
0
func TestRequireEndpointIfNoRegionProvided(t *testing.T) {
	svc := iotdataplane.New(&aws.Config{
		Region:                 aws.String(""),
		DisableParamValidation: aws.Bool(true),
	})
	req, _ := svc.GetThingShadowRequest(nil)
	err := req.Build()

	assert.Equal(t, "", svc.Endpoint)
	assert.Error(t, err)
	assert.Equal(t, aws.ErrMissingEndpoint, err)
}
Пример #3
0
func init() {
	Before("@iotdataplane", func() {
		svc := iot.New(nil)
		result, err := svc.DescribeEndpoint(&iot.DescribeEndpointInput{})
		if err != nil {
			World["error"] = err
			return
		}

		World["client"] = iotdataplane.New(aws.NewConfig().
			WithEndpoint(*result.EndpointAddress))
	})
}
Пример #4
0
func ExampleIoTDataPlane_GetThingShadow() {
	svc := iotdataplane.New(nil)

	params := &iotdataplane.GetThingShadowInput{
		ThingName: aws.String("ThingName"), // Required
	}
	resp, err := svc.GetThingShadow(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Пример #5
0
func ExampleIoTDataPlane_Publish() {
	svc := iotdataplane.New(nil)

	params := &iotdataplane.PublishInput{
		Topic:   aws.String("Topic"), // Required
		Payload: []byte("PAYLOAD"),
		Qos:     aws.Int64(1),
	}
	resp, err := svc.Publish(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Пример #6
0
func TestInterface(t *testing.T) {
	assert.Implements(t, (*iotdataplaneiface.IoTDataPlaneAPI)(nil), iotdataplane.New(nil))
}