diff --git a/iota-device.go b/iota-device.go index 6cc3dd4..7110dfe 100644 --- a/iota-device.go +++ b/iota-device.go @@ -84,7 +84,7 @@ func (i IoTA) ReadDevice(fs FiwareService, id DeciveId) (*Device, error) { } var device Device - err = json.Unmarshal(responseData, &device) + json.Unmarshal(responseData, &device) if err != nil { log.Panic().Err(err).Msg("Could not Marshal struct") } @@ -205,6 +205,8 @@ func (i IoTA) UpdateDevice(fs FiwareService, d Device) error { // Ensure these fields are not set d.Id = "" d.Transport = "" + d.Service = "" + d.ServicePath = "" method := "PUT" diff --git a/main_test.go b/main_test.go index 1dbf3a4..f73d648 100644 --- a/main_test.go +++ b/main_test.go @@ -36,20 +36,49 @@ func TestMain(m *testing.M) { log.Info().Msgf("Starting test with iot-agent host: %s", host) iota = *i.NewIoTAgent(host, 4061, 1000) fs = i.FiwareService{Service: service, ServicePath: servicePath} - d = i.Device{Id: deviceId, EntityName: entityName} + d = i.Device{ + Id: deviceId, + Service: service, + ServicePath: servicePath, + EntityName: entityName, + EntityType: "", + Timezone: "", + Timestamp: new(bool), + Apikey: apiKey, + Endpoint: "", + Protocol: "", + Transport: "", + Attributes: []i.Attribute{}, + Commands: []i.Command{}, + Lazy: []i.LazyAttribute{}, + StaticAttributes: []i.StaticAttribute{}, + InternalAttributes: []interface{}{}, + ExplicitAttrs: true, + NgsiVersion: "", + PayloadType: "", + } sg = i.ConfigGroup{ - Service: service, - ServicePath: servicePath, - Resource: resource, - Apikey: apiKey, - EntityType: "Test", - Autoprovision: false, - StaticAttributes: []i.StaticAttribute{{ - Name: "test", - Type: "Number", - Value: 6, - Metadata: map[string]i.Metadata{}, - }}, + Service: service, + ServicePath: servicePath, + Resource: resource, + Apikey: apiKey, + Timestamp: new(bool), + EntityType: "Test", + Trust: "", + CbHost: host, + Lazy: []i.LazyAttribute{}, + Commands: []i.Command{}, + Attributes: []i.Attribute{}, + StaticAttributes: []i.StaticAttribute{{Name: "test", Type: "Number", Value: 6, Metadata: map[string]i.Metadata{}}}, + InternalAttributes: []interface{}{}, + ExplicitAttrs: "", + EntityNameExp: entityName, + NgsiVersion: "", + DefaultEntityNameConjunction: entityName, + Autoprovision: false, + PayloadType: "", + Transport: "", + Endpoint: "", } iota.DeleteDevice(fs, d.Id) err := iota.CreateDevice(fs, d)