-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtriggers_test.go
More file actions
47 lines (43 loc) · 902 Bytes
/
triggers_test.go
File metadata and controls
47 lines (43 loc) · 902 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
43
44
45
46
47
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTemp(t *testing.T) {
tests := []struct {
name string
param int
expected bool
}{
{">", 200, true},
{">=", 200, true},
{"<", 200, false},
{"<=", 200, false},
{"==", 200, false},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, compareSensorReading(test.name, func() float64 {
return 250
})(float64(test.param)), test.expected)
})
}
}
func TestWeight(t *testing.T) {
tests := []struct {
name string
param int
expected bool
}{
{"weight_>", 200, true},
{"weight_>=", 200, true},
{"weight_<", 200, false},
{"weight_<=", 200, false},
{"weight_==", 200, false},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, Triggers[test.name](float64(test.param)), test.expected)
})
}
}