@@ -62,7 +62,7 @@ var _ = Describe("ValidateBasalRateSchedule", func() {
6262 errorsTest .ExpectEqual (validator .Error (), expected )
6363 })
6464
65- It ("returns an error with a value low than the pump min supported value" , func () {
65+ It ("returns an error with a value lower than the pump min supported value" , func () {
6666 var schedule pump.BasalRateStartArray = []* pump.BasalRateStart {
6767 {Rate : pointer .FromFloat64 (0.55 )},
6868 {Rate : pointer .FromFloat64 (0.0 )},
@@ -72,4 +72,18 @@ var _ = Describe("ValidateBasalRateSchedule", func() {
7272 guardrails .ValidateBasalRateSchedule (schedule , guardRail , validator )
7373 errorsTest .ExpectEqual (validator .Error (), expected )
7474 })
75+
76+ It ("returns an error when the number of segments is higher than the guardrail" , func () {
77+ maxSegments := int32 (2 )
78+ guardRail .MaxSegments = & maxSegments
79+ var schedule pump.BasalRateStartArray = []* pump.BasalRateStart {
80+ {Rate : pointer .FromFloat64 (0.55 )},
81+ {Rate : pointer .FromFloat64 (15.55 )},
82+ {Rate : pointer .FromFloat64 (16.55 )},
83+ }
84+
85+ expected := errorsTest .WithPointerSource (structureValidator .ErrorLengthNotLessThanOrEqualTo (3 , 2 ), "" )
86+ guardrails .ValidateBasalRateSchedule (schedule , guardRail , validator )
87+ errorsTest .ExpectEqual (validator .Error (), expected )
88+ })
7589})
0 commit comments