Skip to content

Commit

Permalink
Implement list of capabilities for gateway.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwood committed May 23, 2024
1 parent 96f5f44 commit 38d740c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
15 changes: 13 additions & 2 deletions gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,19 @@ type gateway struct {
}

func (g *gateway) Capabilities() []da.Capability {
//TODO implement me
panic("implement me")
caps := map[da.Capability]struct{}{capabilities.DeviceRemovalFlag: {}, capabilities.EnumerateDeviceFlag: {}}

for _, c := range factory.Mapping {
caps[c] = struct{}{}
}

var capSlice []da.Capability

for c := range caps {
capSlice = append(capSlice, c)
}

return capSlice
}

func (g *gateway) Self() da.Device {
Expand Down
12 changes: 12 additions & 0 deletions gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,15 @@ func Test_gateway_Devices(t *testing.T) {
assert.Contains(t, devices, gw.Self())
})
}

func Test_gateway_Capabilities(t *testing.T) {
t.Run("contains expected capabilities", func(t *testing.T) {
gw := gateway{}

caps := gw.Capabilities()

assert.Contains(t, caps, capabilities.DeviceRemovalFlag)
assert.Contains(t, caps, capabilities.EnumerateDeviceFlag)
assert.Contains(t, caps, capabilities.ProductInformationFlag)
})
}

0 comments on commit 38d740c

Please sign in to comment.