Skip to content

Commit

Permalink
add story test
Browse files Browse the repository at this point in the history
  • Loading branch information
FoseFx committed Oct 9, 2024
1 parent 6cac7ec commit 16dac7b
Showing 1 changed file with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package stories

import (
"context"
pb "gen/services/property_svc/v1"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"hwtesting"
"testing"
)

func TestGetAttachedPropertyValuesAlwaysInclude(t *testing.T) {
ctx := context.Background()
propertyClient := propertyServiceClient()
propertyValueClient := propertyValueServiceClient()
propertyViewClient := propertyViewServiceClient()

patientID := uuid.New().String()

// Create a property
property, err := propertyClient.CreateProperty(ctx, &pb.CreatePropertyRequest{
SubjectType: pb.SubjectType_SUBJECT_TYPE_PATIENT,
FieldType: pb.FieldType_FIELD_TYPE_NUMBER,
Name: t.Name(),
Description: nil,
})
assert.NoError(t, err)
hwtesting.WaitForProjectionsToSettle()

// Don't create a property value

// Add property to the always_include list of an arbitrary subject
_, err = propertyViewClient.UpdatePropertyViewRule(ctx, &pb.UpdatePropertyViewRuleRequest{
FilterUpdate: &pb.FilterUpdate{
AppendToAlwaysInclude: []string{property.PropertyId},
},
Matcher: &pb.UpdatePropertyViewRuleRequest_PatientMatcher{
PatientMatcher: &pb.PatientPropertyMatcher{
WardId: nil,
PatientId: &patientID,
},
},
})
assert.NoError(t, err)
hwtesting.WaitForProjectionsToSettle()

// Call GetAttachedPropertyValues for this arbitrary patient or task

res, err := propertyValueClient.GetAttachedPropertyValues(ctx, &pb.GetAttachedPropertyValuesRequest{
Matcher: &pb.GetAttachedPropertyValuesRequest_PatientMatcher{
PatientMatcher: &pb.PatientPropertyMatcher{
WardId: nil,
PatientId: &patientID,
},
},
})
assert.NoError(t, err)

// Property shows up
assert.Len(t, res.Values, 1)
assert.Equal(t, res.Values[0].PropertyId, property.PropertyId)

}

0 comments on commit 16dac7b

Please sign in to comment.