Skip to content

Commit e442b47

Browse files
committed
WIP updated updatedTime when modifying providerConnectionRequests
BACK-4414
1 parent 5e352dd commit e442b47

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

patients/repository/repository.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ func (r *repository) AddProviderConnectionRequest(ctx context.Context, clinicId,
891891

892892
key := "providerConnectionRequests." + request.ProviderName
893893
update := bson.M{
894+
"$currentDate": bson.M{"updatedTime": true},
894895
"$push": bson.M{
895896
key: bson.M{
896897
"$each": bson.A{request},

patients/repository/repository_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,15 +1825,6 @@ var _ = Describe("Patients Repository", func() {
18251825
})
18261826

18271827
Describe("Add provider connection request", func() {
1828-
BeforeEach(func() {
1829-
dataSources := patients.DataSources{{
1830-
ProviderName: patients.DexcomDataSourceProviderName,
1831-
State: "pending",
1832-
}}
1833-
err := repo.UpdatePatientDataSources(context.Background(), *randomPatient.UserId, &dataSources)
1834-
Expect(err).ToNot(HaveOccurred())
1835-
})
1836-
18371828
It("correctly adds multiple requests", func() {
18381829
request := patients.ConnectionRequest{
18391830
ProviderName: patients.DexcomDataSourceProviderName,
@@ -1843,6 +1834,7 @@ var _ = Describe("Patients Repository", func() {
18431834
err := repo.AddProviderConnectionRequest(context.Background(), randomPatient.ClinicId.Hex(), *randomPatient.UserId, request)
18441835
Expect(err).ToNot(HaveOccurred())
18451836

1837+
updatedTime := time.Now()
18461838
err = repo.AddProviderConnectionRequest(context.Background(), randomPatient.ClinicId.Hex(), *randomPatient.UserId, request)
18471839
Expect(err).ToNot(HaveOccurred())
18481840

@@ -1858,6 +1850,8 @@ var _ = Describe("Patients Repository", func() {
18581850
Expect(dexcom[0].ProviderName).To(BeComparableTo(request.ProviderName))
18591851
Expect(dexcom[1].CreatedTime).To(BeComparableTo(request.CreatedTime))
18601852
Expect(dexcom[1].ProviderName).To(BeComparableTo(request.ProviderName))
1853+
1854+
Expect(patient.UpdatedTime).To(BeTemporally("~", updatedTime))
18611855
})
18621856
})
18631857

0 commit comments

Comments
 (0)