-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig_test.go
116 lines (88 loc) · 3.13 KB
/
config_test.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package openminder
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestAssignProbeSerials(t *testing.T) {
Convey("given a config", t, func() {
cfg := &Config{}
Convey("with the runoff serial set", func() {
cfg.RunoffECProbe = "1234"
Convey("when a pair of serials is given, with the first identical to the runoff serial", func() {
cfg.AssignProbeSerials("1234", "6789")
Convey("it should not overwrite the runoff serial", func() {
So(cfg.RunoffECProbe, ShouldEqual, "1234")
})
Convey("it should set the irrig serial", func() {
So(cfg.IrrigECProbe, ShouldEqual, "6789")
})
})
Convey("when a pair of serials is given, with the second identical to the runoff serial", func() {
cfg.AssignProbeSerials("6789", "1234")
Convey("it should not overwrite the runoff serial", func() {
So(cfg.RunoffECProbe, ShouldEqual, "1234")
})
Convey("it should set the irrig serial", func() {
So(cfg.IrrigECProbe, ShouldEqual, "6789")
})
})
})
Convey("with the irrig serial set", func() {
cfg.IrrigECProbe = "1234"
Convey("when a pair of serials is given, with the first identical to the irrig serial", func() {
cfg.AssignProbeSerials("1234", "6789")
Convey("it should not overwrite the irrig serial", func() {
So(cfg.IrrigECProbe, ShouldEqual, "1234")
})
Convey("it should set the runoff serial", func() {
So(cfg.RunoffECProbe, ShouldEqual, "6789")
})
})
Convey("when a pair of serials is given, with the second identical to the irrig serial", func() {
cfg.AssignProbeSerials("6789", "1234")
Convey("it should not overwrite the irrig serial", func() {
So(cfg.IrrigECProbe, ShouldEqual, "1234")
})
Convey("it should set the runoff serial", func() {
So(cfg.RunoffECProbe, ShouldEqual, "6789")
})
})
})
Convey("with both serial numbers are set", func() {
cfg.IrrigECProbe = "1234"
cfg.RunoffECProbe = "6789"
Convey("and two new serial numbers come in", func() {
cfg.AssignProbeSerials("abcd", "efgh")
Convey("it should assign the new serial numbers", func() {
So(cfg.RunoffECProbe, ShouldEqual, "abcd")
So(cfg.IrrigECProbe, ShouldEqual, "efgh")
})
})
Convey("and identical serial numbers come in", func() {
cfg.AssignProbeSerials("6789", "1234")
Convey("they should not be reassigned", func() {
So(cfg.RunoffECProbe, ShouldEqual, "6789")
So(cfg.IrrigECProbe, ShouldEqual, "1234")
})
})
Convey("and identical serial numbers come in, reversed", func() {
cfg.AssignProbeSerials("1234", "6789")
Convey("they should not be reassigned", func() {
So(cfg.RunoffECProbe, ShouldEqual, "6789")
So(cfg.IrrigECProbe, ShouldEqual, "1234")
})
})
})
Convey("with both serial numbers are not set", func() {
cfg.IrrigECProbe = ""
cfg.RunoffECProbe = ""
Convey("and two new serial numbers come in", func() {
cfg.AssignProbeSerials("abcd", "efgh")
Convey("it should assign the new serial numbers", func() {
So(cfg.RunoffECProbe, ShouldEqual, "abcd")
So(cfg.IrrigECProbe, ShouldEqual, "efgh")
})
})
})
})
}