Skip to content

Commit

Permalink
update test sleepSchedules creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Nov 7, 2023
1 parent 8b01eb2 commit f075c22
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions data/types/settings/pump/pump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,13 +634,13 @@ var _ = Describe("Pump", func() {
Entry("sleep schedules valid",
pointer.FromString("mmol/L"),
func(datum *pump.Pump, unitsBloodGlucose *string) {
datum.SleepSchedules = pumpTest.RandomSleepSchedules(0, 10)
datum.SleepSchedules = pumpTest.RandomSleepSchedules(3)
},
),
Entry("sleep schedules invalid",
pointer.FromString("mmol/L"),
func(datum *pump.Pump, unitsBloodGlucose *string) {
datum.SleepSchedules = pumpTest.RandomSleepSchedules(2, 2)
datum.SleepSchedules = pumpTest.RandomSleepSchedules(2)
(*datum.SleepSchedules)[pumpTest.SleepScheduleName(0)].End = pointer.FromInt(pump.SleepSchedulesMidnightOffsetMaximum + 1)
},
errorsTest.WithPointerSourceAndMeta(structureValidator.ErrorValueNotInRange(
Expand Down
8 changes: 4 additions & 4 deletions data/types/settings/pump/sleep_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _ = Describe("SleepSchedule", func() {
Context("Validate", func() {
DescribeTable("validates the datum",
func(mutator func(datum *dataTypesSettingsPump.SleepScheduleMap), expectedErrors ...error) {
datum := dataTypesSettingsPumpTest.RandomSleepSchedules(1, 3)
datum := dataTypesSettingsPumpTest.RandomSleepSchedules(3)
mutator(datum)
errorsTest.ExpectEqual(structureValidator.New().Validate(datum), expectedErrors...)
},
Expand All @@ -45,12 +45,12 @@ var _ = Describe("SleepSchedule", func() {
),
Entry("has one",
func(datum *dataTypesSettingsPump.SleepScheduleMap) {
*datum = *dataTypesSettingsPumpTest.RandomSleepSchedules(1, 1)
*datum = *dataTypesSettingsPumpTest.RandomSleepSchedules(1)
},
),
Entry("has many",
func(datum *dataTypesSettingsPump.SleepScheduleMap) {
*datum = *dataTypesSettingsPumpTest.RandomSleepSchedules(100, 100)
*datum = *dataTypesSettingsPumpTest.RandomSleepSchedules(19)
},
),
Entry("entry missing",
Expand All @@ -61,7 +61,7 @@ var _ = Describe("SleepSchedule", func() {
),
Entry("multiple errors",
func(datum *dataTypesSettingsPump.SleepScheduleMap) {
*datum = *dataTypesSettingsPumpTest.RandomSleepSchedules(3, 3)
*datum = *dataTypesSettingsPumpTest.RandomSleepSchedules(3)
(*datum)[dataTypesSettingsPumpTest.SleepScheduleName(1)] = nil
},
errorsTest.WithPointerSource(structureValidator.ErrorValueNotExists(), fmt.Sprintf("/%s", dataTypesSettingsPumpTest.SleepScheduleName(1))),
Expand Down
3 changes: 1 addition & 2 deletions data/types/settings/pump/test/sleep_scheduled.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ func SleepScheduleName(index int) string {
return fmt.Sprintf("schedule-%d", index)
}

func RandomSleepSchedules(minimumLength int, maximumLength int) *dataTypesSettingsPump.SleepScheduleMap {
count := test.RandomIntFromRange(minimumLength, maximumLength)
func RandomSleepSchedules(count int) *dataTypesSettingsPump.SleepScheduleMap {
datum := dataTypesSettingsPump.NewSleepScheduleMap()
for i := 0; i < count; i++ {
(*datum)[SleepScheduleName(i)] = RandomSleepSchedule()
Expand Down

0 comments on commit f075c22

Please sign in to comment.