-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdash_button_event_handler_test.go
More file actions
42 lines (39 loc) · 1023 Bytes
/
dash_button_event_handler_test.go
File metadata and controls
42 lines (39 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package buttonoff
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDuplicateButtonIDs(t *testing.T) {
buttonID := "DUP"
buttons := []ButtonConfig{
{ButtonID: buttonID, HWAddr: "aa:aa:aa:aa:aa:aa"},
{ButtonID: buttonID, HWAddr: "bb:bb:bb:bb:bb:bb"},
{ButtonID: buttonID, HWAddr: "ff:ff:ff:ff:ff:ff"},
}
events := []Event{
{
HWAddr: buttons[0].HWAddr,
Timestamp: time.Now(),
},
{
HWAddr: buttons[1].HWAddr,
Timestamp: time.Now(),
},
{
HWAddr: buttons[2].HWAddr,
Timestamp: time.Now(),
},
}
handler, err := NewDashButtonEventHandler(GeneralConfig{
DropUnconfigured: true,
PostPressSupressPeriod: time.Second * 1,
TopicTemplate: DefaultDashButtonTopicTemplate,
}, buttons, (Publisher)(nil))
require.NoError(t, err)
for _, event := range events {
id := handler.getRegistryButtonID(event)
assert.Equal(t, buttonID, id, "expected the button id to be the same for each event")
}
}