Skip to content

Commit

Permalink
Fix Dexcom API v2 edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Darin Krauss committed Nov 13, 2018
1 parent 1fd74e7 commit 4dee948
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## v1.30.0

* Fix Dexcom API v2 edge cases
* Handle unexpected data from Dexcom API v2
* Update to Dexcom API v2
* Capture cgm settings for changed Dexcom API devices
Expand Down
16 changes: 8 additions & 8 deletions data/types/insulin/formulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ var _ = Describe("Formulation", func() {
func(datum *insulin.Formulation) {
datum.Compounds = nil
datum.Simple = testDataTypesInsulin.NewSimple()
datum.Simple.Concentration = nil
datum.Simple.ActingType = nil
},
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/simple/concentration"),
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/simple/actingType"),
),
Entry("compounds missing; simple valid",
func(datum *insulin.Formulation) {
Expand All @@ -87,10 +87,10 @@ var _ = Describe("Formulation", func() {
datum.Compounds = insulin.NewCompoundArray()
*datum.Compounds = append(*datum.Compounds, nil)
datum.Simple = testDataTypesInsulin.NewSimple()
datum.Simple.Concentration = nil
datum.Simple.ActingType = nil
},
testErrors.WithPointerSource(structureValidator.ErrorValueExists(), "/compounds"),
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/simple/concentration"),
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/simple/actingType"),
),
Entry("compounds invalid; simple valid",
func(datum *insulin.Formulation) {
Expand All @@ -110,10 +110,10 @@ var _ = Describe("Formulation", func() {
func(datum *insulin.Formulation) {
datum.Compounds = testDataTypesInsulin.NewCompoundArray(3)
datum.Simple = testDataTypesInsulin.NewSimple()
datum.Simple.Concentration = nil
datum.Simple.ActingType = nil
},
testErrors.WithPointerSource(structureValidator.ErrorValueExists(), "/compounds"),
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/simple/concentration"),
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/simple/actingType"),
),
Entry("compounds valid; simple valid",
func(datum *insulin.Formulation) {
Expand Down Expand Up @@ -141,11 +141,11 @@ var _ = Describe("Formulation", func() {
datum.Compounds = testDataTypesInsulin.NewCompoundArray(3)
datum.Name = pointer.FromString("")
datum.Simple = testDataTypesInsulin.NewSimple()
datum.Simple.Concentration = nil
datum.Simple.ActingType = nil
},
testErrors.WithPointerSource(structureValidator.ErrorValueExists(), "/compounds"),
testErrors.WithPointerSource(structureValidator.ErrorValueEmpty(), "/name"),
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/simple/concentration"),
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/simple/actingType"),
),
)
})
Expand Down
3 changes: 0 additions & 3 deletions data/types/insulin/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package insulin
import (
"github.com/tidepool-org/platform/data"
"github.com/tidepool-org/platform/structure"
structureValidator "github.com/tidepool-org/platform/structure/validator"
)

const (
Expand Down Expand Up @@ -54,8 +53,6 @@ func (s *Simple) Validate(validator structure.Validator) {
validator.String("brand", s.Brand).NotEmpty().LengthLessThanOrEqualTo(SimpleBrandLengthMaximum)
if s.Concentration != nil {
s.Concentration.Validate(validator.WithReference("concentration"))
} else {
validator.WithReference("concentration").ReportError(structureValidator.ErrorValueNotExists())
}
}

Expand Down
5 changes: 2 additions & 3 deletions data/types/insulin/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ var _ = Describe("Simple", func() {
),
Entry("concentration missing",
func(datum *insulin.Simple) { datum.Concentration = nil },
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/concentration"),
),
Entry("concentration invalid",
func(datum *insulin.Simple) { datum.Concentration.Units = nil },
Expand All @@ -115,11 +114,11 @@ var _ = Describe("Simple", func() {
func(datum *insulin.Simple) {
datum.ActingType = nil
datum.Brand = pointer.FromString("")
datum.Concentration = nil
datum.Concentration.Units = nil
},
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/actingType"),
testErrors.WithPointerSource(structureValidator.ErrorValueEmpty(), "/brand"),
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/concentration"),
testErrors.WithPointerSource(structureValidator.ErrorValueNotExists(), "/concentration/units"),
),
)
})
Expand Down
2 changes: 1 addition & 1 deletion dexcom/fetch/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func translateAlertScheduleSettingsDaysOfWeekToScheduledAlertDays(daysOfWeek *[]
if daysOfWeek == nil {
return nil
}
var days []string
days := []string{}
for _, dayOfWeek := range *daysOfWeek {
days = append(days, translateAlertScheduleSettingsDayOfWeekToScheduledAlertDay(dayOfWeek))
}
Expand Down

0 comments on commit 4dee948

Please sign in to comment.