Skip to content

Commit 3aba6e0

Browse files
authored
Merge pull request #908 from tidepool-org/BACK-3960-oura-connection
- Add Oura functionality - Placeholder PR to list all approved, predecessor PRs: - #901 - #903 - #904 - #905 - #906 - #907 - #911 - #912 - #913 - #916 - #917 - #919 - #920 - #921 - #922 - #923 - #924 - #925 - #926 - #927 - #928 - #929 - #930 - #933 - #934 - #935 - #936 - #937 - #938 - #939 - #943 - #946 - #947 - #948 - #949 - #950 - #951 - #952 - #953 - #957
2 parents dab2c61 + 9660a22 commit 3aba6e0

457 files changed

Lines changed: 153543 additions & 7422 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ginkgo/templates/bootstrap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package {{.Package}}
2+
3+
import (
4+
"testing"
5+
6+
"github.com/tidepool-org/platform/test"
7+
)
8+
9+
func TestSuite(t *testing.T) {
10+
test.Test(t)
11+
}

.ginkgo/templates/generate

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{.BuildTags}}
2+
package {{.Package}}
3+
4+
import (
5+
{{.GinkgoImport}}
6+
{{.GomegaImport}}
7+
. "github.com/onsi/gomega/gstruct"
8+
9+
{{if .ImportPackage}}"{{.PackageImportPath}}"{{end}}
10+
"github.com/tidepool-org/platform/test"
11+
)
12+
13+
var _ = {{.GinkgoPackage}}Describe("{{.Subject}}", func() {
14+
// TODO
15+
})

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ _tmp
2929
# Development
3030
.gvm_local
3131
.idea
32+
.vscode
3233
*.code-workspace

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,3 @@ addons:
4242
script:
4343
- export TIMING_CMD='time -p'
4444
- make "plugins-visibility-${PLUGINS_VISIBILITY}" && make ci
45-

.vscode/launch.json

Lines changed: 0 additions & 109 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

Makefile

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ GINKGO_FLAGS += --require-suite --poll-progress-after=10s --poll-progress-interv
4949
GINKGO_CI_WATCH_FLAGS += --randomize-all --succinct --fail-on-pending --cover --trace --race
5050
GINKGO_CI_FLAGS += $(GINKGO_CI_WATCH_FLAGS) --randomize-suites --keep-going
5151

52+
ifdef TEST
53+
TEST_PACKAGE=$(shell [ -d "$(TEST)" ] && echo "$(TEST)" || dirname "$(TEST)")
54+
TEST_PACKAGE_NAME=$(notdir $(TEST_PACKAGE))
55+
TEST_DIRECTORY=$(realpath $(TEST_PACKAGE))
56+
TEST_FILE=$(notdir $(TEST))
57+
endif
58+
59+
TEST_REPEAT ?= 1
60+
5261
DOCKER_LOGIN_CMD ?= docker login
5362
DOCKER_BUILD_CMD ?= docker build
5463
DOCKER_PUSH_CMD ?= docker push
@@ -263,38 +272,42 @@ ci-test: ci-test-go
263272
test-ginkgo: ginkgo
264273
@echo "ginkgo $(GINKGO_FLAGS) $(TEST)"
265274
@cd $(ROOT_DIRECTORY) && \
266-
{ [ -z `go env GOWORK` ] || GOWORK_FLAGS=-mod=readonly; } && \
267-
. ./env.test.sh && $(TIMING_CMD) ginkgo $(GINKGO_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
275+
. ./env.test.sh && GOWORK=off $(TIMING_CMD) ginkgo $(GINKGO_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
276+
277+
test-ginkgo-repeat: ginkgo
278+
@echo "ginkgo $(GINKGO_FLAGS) --repeat $(TEST_REPEAT) $(TEST)"
279+
@cd $(ROOT_DIRECTORY) && \
280+
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) --repeat $(TEST_REPEAT) $${GOWORK_FLAGS:-} $(TEST)
268281

269282
test-ginkgo-until-failure: ginkgo
270-
@echo "ginkgo $(GINKGO_FLAGS) -untilItFails $(TEST)"
283+
@echo "ginkgo $(GINKGO_FLAGS) --until-it-fails $(TEST)"
271284
@cd $(ROOT_DIRECTORY) && \
272-
{ [ -z `go env GOWORK` ] || GOWORK_FLAGS=-mod=readonly; } && \
273-
. ./env.test.sh && ginkgo $(GINKGO_FLAGS) -untilItFails $${GOWORK_FLAGS:-} $(TEST)
285+
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) --until-it-fails $${GOWORK_FLAGS:-} $(TEST)
274286

275287
test-ginkgo-watch: ginkgo
276288
@echo "ginkgo watch $(GINKGO_FLAGS) $(TEST)"
277289
@cd $(ROOT_DIRECTORY) && \
278-
{ [ -z `go env GOWORK` ] || GOWORK_FLAGS=-mod=readonly; } && \
279-
. ./env.test.sh && ginkgo watch $(GINKGO_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
290+
. ./env.test.sh && GOWORK=off ginkgo watch $(GINKGO_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
280291

281292
ci-test-ginkgo: ginkgo
282293
@echo "ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) $(TEST)"
283294
@cd $(ROOT_DIRECTORY) && \
284-
{ [ -z `go env GOWORK` ] || GOWORK_FLAGS=-mod=readonly; } && \
285-
. ./env.test.sh && $(TIMING_CMD) ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
295+
. ./env.test.sh && GOWORK=off $(TIMING_CMD) ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
296+
297+
ci-test-ginkgo-repeat: ginkgo
298+
@echo "ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --repeat $(TEST_REPEAT) $(TEST)"
299+
@cd $(ROOT_DIRECTORY) && \
300+
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --repeat $(TEST_REPEAT) $${GOWORK_FLAGS:-} $(TEST)
286301

287302
ci-test-ginkgo-until-failure: ginkgo
288-
@echo "ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) -untilItFails $(TEST)"
303+
@echo "ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --until-it-fails $(TEST)"
289304
@cd $(ROOT_DIRECTORY) && \
290-
{ [ -z `go env GOWORK` ] || GOWORK_FLAGS=-mod=readonly; } && \
291-
. ./env.test.sh && ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) -untilItFails $${GOWORK_FLAGS:-} $(TEST)
305+
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --until-it-fails $${GOWORK_FLAGS:-} $(TEST)
292306

293307
ci-test-ginkgo-watch: ginkgo
294308
@echo "ginkgo watch $(GINKGO_FLAGS) $(GINKGO_CI_WATCH_FLAGS) $(TEST)"
295309
@cd $(ROOT_DIRECTORY) && \
296-
{ [ -z `go env GOWORK` ] || GOWORK_FLAGS=-mod=readonly; } && \
297-
. ./env.test.sh && ginkgo watch $(GINKGO_FLAGS) $(GINKGO_CI_WATCH_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
310+
. ./env.test.sh && GOWORK=off ginkgo watch $(GINKGO_FLAGS) $(GINKGO_CI_WATCH_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
298311

299312
test-go:
300313
@echo "go test $(GOTEST_FLAGS) $(GOTEST_PKGS)"
@@ -306,6 +319,21 @@ ci-test-go: GOTEST_FLAGS += -count=1 -race -shuffle=on -cover
306319
ci-test-go: GOTEST_PKGS = ./...
307320
ci-test-go: test-go
308321

322+
ginkgo-bootstrap: ginkgo
323+
ifdef TEST
324+
@echo "ginkgo bootstrap $(TEST_PACKAGE)"
325+
@cd "$(TEST_DIRECTORY)" && \
326+
[ -f "$(TEST_PACKAGE_NAME)_suite_test.go" ] || \
327+
ginkgo bootstrap --template "$(ROOT_DIRECTORY)/.ginkgo/templates/bootstrap"
328+
endif
329+
330+
ginkgo-generate: ginkgo-bootstrap
331+
ifdef TEST
332+
@echo "ginkgo generate $(TEST)"
333+
@cd "$(TEST_DIRECTORY)" && \
334+
ginkgo generate --template "$(ROOT_DIRECTORY)/.ginkgo/templates/generate" $(TEST_FILE)
335+
endif
336+
309337
service-build:
310338
ifdef SERVICE
311339
@$(MAKE) build BUILD=$${SERVICE}
@@ -415,14 +443,14 @@ phony:
415443

416444
.PHONY: bindir build build-list build-watch buildable ci ci-build \
417445
ci-build-watch ci-docker ci-generate ci-init ci-test ci-test-ginkgo \
418-
ci-test-ginkgo-until-failure ci-test-ginkgo-watch ci-test-go clean clean-all \
419-
clean-bin clean-cover clean-debug clean-generate clean-test clean-version \
420-
CompileDaemon default docker docker-build docker-dump docker-login docker-push \
421-
format format-write format-write-changed generate ginkgo go-generate \
422-
go-mod-download go-mod-tidy goimports imports imports-write \
423-
imports-write-changed init mockgen phony plugin-visibility \
424-
plugin-visibility-private plugin-visibility-public plugins-visibility \
425-
plugins-visibility-private plugins-visibility-public pre-commit service-build \
426-
service-debug service-restart service-restart-all service-start test \
427-
test-ginkgo test-ginkgo-until-failure test-ginkgo-watch test-go tmp \
428-
version-write vet vet-ignore
446+
ci-test-ginkgo-repeat ci-test-ginkgo-until-failure ci-test-ginkgo-watch \
447+
ci-test-go clean clean-all clean-bin clean-cover clean-debug clean-generate \
448+
clean-test clean-version CompileDaemon default docker docker-build docker-dump \
449+
docker-login docker-push format format-write format-write-changed generate \
450+
ginkgo ginkgo-bootstrap ginkgo-generate go-generate go-mod-download go-mod-tidy \
451+
goimports imports imports-write imports-write-changed init mockgen phony \
452+
plugin-visibility plugin-visibility-private plugin-visibility-public \
453+
plugins-visibility plugins-visibility-private plugins-visibility-public \
454+
pre-commit service-build service-debug service-restart service-restart-all \
455+
service-start test test-ginkgo test-ginkgo-repeat test-ginkgo-until-failure \
456+
test-ginkgo-watch test-go tmp version-write vet vet-ignore

alerts/config_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var _ = Describe("Config", func() {
7272
}
7373
}`, mockUserID1, mockUserID2, mockUploadID)
7474
conf := &Config{}
75-
err := request.DecodeObject(context.Background(), nil, buf, conf)
75+
err := request.DecodeStream(context.Background(), nil, buf, conf)
7676
Expect(err).ToNot(HaveOccurred())
7777
Expect(conf.UserID).To(Equal(mockUserID1))
7878
Expect(conf.FollowedUserID).To(Equal(mockUserID2))
@@ -358,7 +358,7 @@ var _ = Describe("Config", func() {
358358
It("validates threshold units", func() {
359359
buf := buff(`{"urgentLow": {"threshold": {"units":"%s","value":42}}`, "garbage")
360360
threshold := &Threshold{}
361-
err := request.DecodeObject(context.Background(), nil, buf, threshold)
361+
err := request.DecodeStream(context.Background(), nil, buf, threshold)
362362
Expect(err).To(MatchError("json is malformed"))
363363
})
364364
It("validates repeat minutes (negative)", func() {
@@ -376,7 +376,7 @@ var _ = Describe("Config", func() {
376376
}
377377
}`, mockUserID1, mockUserID2, mockUploadID, glucose.MgdL)
378378
cfg := &Config{}
379-
err := request.DecodeObject(context.Background(), nil, buf, cfg)
379+
err := request.DecodeStream(context.Background(), nil, buf, cfg)
380380
Expect(err).To(MatchError("value -11m0s is not greater than or equal to 15m0s"))
381381
})
382382
It("validates repeat minutes (string)", func() {
@@ -393,7 +393,7 @@ var _ = Describe("Config", func() {
393393
}
394394
}`, mockUserID1, mockUserID2, glucose.MgdL)
395395
cfg := &Config{}
396-
err := request.DecodeObject(context.Background(), nil, buf, cfg)
396+
err := request.DecodeStream(context.Background(), nil, buf, cfg)
397397
Expect(err).To(MatchError("json is malformed"))
398398
})
399399
})
@@ -414,7 +414,7 @@ var _ = Describe("Config", func() {
414414
}
415415
}`, mockUserID1, mockUserID2, mockUploadID)
416416
conf := &Config{}
417-
err := request.DecodeObject(context.Background(), nil, buf, conf)
417+
err := request.DecodeStream(context.Background(), nil, buf, conf)
418418
Expect(err).To(Succeed())
419419
Expect(conf.Low.Repeat).To(Equal(DurationMinutes(0)))
420420
})
@@ -458,33 +458,33 @@ var _ = Describe("Threshold", func() {
458458
It("accepts mg/dL", func() {
459459
buf := buff(`{"units":"%s","value":42}`, glucose.MgdL)
460460
threshold := &Threshold{}
461-
err := request.DecodeObject(context.Background(), nil, buf, threshold)
461+
err := request.DecodeStream(context.Background(), nil, buf, threshold)
462462
Expect(err).To(BeNil())
463463
Expect(threshold.Value).To(Equal(42.0))
464464
Expect(threshold.Units).To(Equal(glucose.MgdL))
465465
})
466466
It("accepts mmol/L", func() {
467467
buf := buff(`{"units":"%s","value":42}`, glucose.MmolL)
468468
threshold := &Threshold{}
469-
err := request.DecodeObject(context.Background(), nil, buf, threshold)
469+
err := request.DecodeStream(context.Background(), nil, buf, threshold)
470470
Expect(err).To(BeNil())
471471
Expect(threshold.Value).To(Equal(42.0))
472472
Expect(threshold.Units).To(Equal(glucose.MmolL))
473473
})
474474
It("rejects lb/gal", func() {
475475
buf := buff(`{"units":"%s","value":42}`, "lb/gal")
476-
err := request.DecodeObject(context.Background(), nil, buf, &Threshold{})
476+
err := request.DecodeStream(context.Background(), nil, buf, &Threshold{})
477477
Expect(err).Should(HaveOccurred())
478478
})
479479
It("rejects blank units", func() {
480480
buf := buff(`{"units":"","value":42}`)
481-
err := request.DecodeObject(context.Background(), nil, buf, &Threshold{})
481+
err := request.DecodeStream(context.Background(), nil, buf, &Threshold{})
482482
Expect(err).Should(HaveOccurred())
483483
})
484484
It("is case-sensitive with respect to Units", func() {
485485
badUnits := strings.ToUpper(glucose.MmolL)
486486
buf := buff(`{"units":"%s","value":42}`, badUnits)
487-
err := request.DecodeObject(context.Background(), nil, buf, &Threshold{})
487+
err := request.DecodeStream(context.Background(), nil, buf, &Threshold{})
488488
Expect(err).Should(HaveOccurred())
489489
})
490490

appvalidate/challenge.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"github.com/tidepool-org/platform/structure"
66
)
77

8+
//go:generate mockgen -source=challenge.go -destination=test/challenge_mocks.go -package=test -typed
9+
810
// ChallengeCreate is the expected request body used to create an attestation
911
// or assertion challenge.
1012
type ChallengeCreate struct {
@@ -29,7 +31,6 @@ func (c *ChallengeCreate) Validate(v structure.Validator) {
2931
v.String("keyId", &c.KeyID).NotEmpty()
3032
}
3133

32-
//go:generate mockgen -source=challenge.go -destination=test/challenge_mocks.go -package=test ChallengeGenerator
3334
type ChallengeGenerator interface {
3435
GenerateChallenge(size int) (string, error)
3536
}

appvalidate/repository.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"github.com/tidepool-org/platform/errors"
77
)
88

9+
//go:generate mockgen -source=repository.go -destination=test/repository_mocks.go -package=test -typed
10+
911
var (
1012
ErrDuplicateKeyId = errors.New("duplicate key id")
1113
ErrKeyIdNotFound = errors.New("key id not found")
@@ -16,7 +18,6 @@ type Filter struct {
1618
KeyID string
1719
}
1820

19-
//go:generate mockgen -source=repository.go -destination=test/repository_mocks.go -package=test Repository
2021
type Repository interface {
2122
IsVerified(ctx context.Context, f Filter) (bool, error)
2223
Get(ctx context.Context, f Filter) (*AppValidation, error)

0 commit comments

Comments
 (0)