Skip to content

Commit

Permalink
updates: pr review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed May 20, 2020
1 parent 4962af6 commit 4842c32
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions sdk/device_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type deviceManager struct {
devices map[string]*Device
handlers map[string]*DeviceHandler

p *Plugin
plugin *Plugin
}

// newDeviceManager creates a new DeviceManager.
Expand All @@ -97,7 +97,7 @@ func newDeviceManager(plugin *Plugin) *deviceManager {
aliasCache: NewAliasCache(),
devices: make(map[string]*Device),
handlers: make(map[string]*DeviceHandler),
p: plugin,
plugin: plugin,
}
}

Expand Down Expand Up @@ -357,7 +357,7 @@ func (manager *deviceManager) AddDevice(device *Device) error {
// If the device ID has not already been set, generate it and set
// it before adding it to the deviceManager.
if device.id == "" {
manager.p.GenerateDeviceID(device)
manager.plugin.GenerateDeviceID(device)
}

// Check if the Device ID collides with an existing device.
Expand Down
16 changes: 8 additions & 8 deletions sdk/device_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,18 +811,18 @@ func TestDeviceManager_AddDevice_aliasExists(t *testing.T) {

func TestDeviceManager_AddDevice(t *testing.T) {
handler := DeviceHandler{Name: "foo"}
pid := &pluginID{uuid: uuid.NewSHA1(uuid.NameSpaceDNS, []byte("test"))}
pluginid := &pluginID{uuid: uuid.NewSHA1(uuid.NameSpaceDNS, []byte("test"))}
m := deviceManager{
aliasCache: NewAliasCache(),
tagCache: NewTagCache(),
id: pid,
id: pluginid,
pluginHandlers: NewDefaultPluginHandlers(),
handlers: map[string]*DeviceHandler{
"foo": &handler,
},
devices: map[string]*Device{},
p: &Plugin{
id: pid,
plugin: &Plugin{
id: pluginid,
pluginHandlers: NewDefaultPluginHandlers(),
},
}
Expand Down Expand Up @@ -1142,18 +1142,18 @@ func TestDeviceManager_createDevices_ok(t *testing.T) {
},
},
}
pid := &pluginID{uuid: uuid.NewSHA1(uuid.NameSpaceDNS, []byte("test"))}
pluginid := &pluginID{uuid: uuid.NewSHA1(uuid.NameSpaceDNS, []byte("test"))}
m := deviceManager{
config: cfg,
tagCache: NewTagCache(),
pluginHandlers: NewDefaultPluginHandlers(),
id: pid,
id: pluginid,
handlers: map[string]*DeviceHandler{
"foo": {Name: "foo"},
},
devices: map[string]*Device{},
p: &Plugin{
id: pid,
plugin: &Plugin{
id: pluginid,
pluginHandlers: NewDefaultPluginHandlers(),
},
}
Expand Down
8 changes: 4 additions & 4 deletions sdk/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,22 +715,22 @@ func TestPlugin_NewDevice(t *testing.T) {

func TestPlugin_AddDevice(t *testing.T) {
handler := DeviceHandler{Name: "foo"}
pid := &pluginID{uuid: uuid.NewSHA1(uuid.NameSpaceDNS, []byte("test"))}
pluginid := &pluginID{uuid: uuid.NewSHA1(uuid.NameSpaceDNS, []byte("test"))}
p := Plugin{
pluginHandlers: NewDefaultPluginHandlers(),
id: pid,
id: pluginid,
device: &deviceManager{
aliasCache: NewAliasCache(),
tagCache: NewTagCache(),
id: pid,
id: pluginid,
pluginHandlers: NewDefaultPluginHandlers(),
handlers: map[string]*DeviceHandler{
"foo": &handler,
},
devices: map[string]*Device{},
},
}
p.device.p = &p
p.device.plugin = &p
device := Device{
Type: "testtype",
Handler: "foo",
Expand Down

0 comments on commit 4842c32

Please sign in to comment.