-
Notifications
You must be signed in to change notification settings - Fork 3
/
ratio_test.go
61 lines (49 loc) · 1.26 KB
/
ratio_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
package openminder
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestCalculateRunoffRatio(t *testing.T) {
Convey("given a default config", t, func() {
cfg := Config{}
Convey("and some volume readings", func() {
r := newReadings()
r.IrrigVolume = 40
r.RunoffVolume = 30
Convey("it should calculate the ratio by volume only", func() {
CalculateRunoffRatio(r, cfg)
So(r.RunoffRatio, ShouldEqual, 0.75)
})
})
Convey("and no volume readings", func() {
r := newReadings()
Convey("it should not calculate the runoff ratio", func() {
CalculateRunoffRatio(r, cfg)
So(r.RunoffRatio, ShouldEqual, 0)
})
})
})
Convey("given a config", t, func() {
cfg := Config{
DrippersPerPlant: 4,
RunoffDrippers: 8,
IrrigDrippers: 2,
}
Convey("and some volume readings", func() {
r := newReadings()
r.IrrigVolume = 80
r.RunoffVolume = 320
Convey("it should calculate the runoff ratio", func() {
CalculateRunoffRatio(r, cfg)
So(r.RunoffRatio, ShouldEqual, 1)
})
})
Convey("and no volume readings", func() {
r := newReadings()
Convey("it should not calculate the runoff ratio", func() {
CalculateRunoffRatio(r, cfg)
So(r.RunoffRatio, ShouldEqual, 0)
})
})
})
}