Skip to content

Commit

Permalink
MLPAB-1416: Send how evidence is being sent to OPG in reduced-fee-req…
Browse files Browse the repository at this point in the history
…uested event (#817)
  • Loading branch information
acsauk authored Nov 7, 2023
1 parent 1bb8856 commit c0de457
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
14 changes: 8 additions & 6 deletions internal/app/donor_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ func (s *donorStore) Put(ctx context.Context, lpa *page.Lpa) error {

if len(unsentKeys) > 0 {
if err := s.eventClient.Send(ctx, "reduced-fee-requested", reducedFeeRequestedEvent{
UID: lpa.UID,
RequestType: lpa.FeeType.String(),
Evidence: unsentKeys,
UID: lpa.UID,
RequestType: lpa.FeeType.String(),
Evidence: unsentKeys,
EvidenceDelivery: lpa.EvidenceDelivery.String(),
}); err != nil {
s.logger.Print(err)
} else {
Expand Down Expand Up @@ -285,7 +286,8 @@ type previousApplicationLinkedEvent struct {
}

type reducedFeeRequestedEvent struct {
UID string `json:"uid"`
RequestType string `json:"requestType"`
Evidence []string `json:"evidence"`
UID string `json:"uid"`
RequestType string `json:"requestType"`
Evidence []string `json:"evidence"`
EvidenceDelivery string `json:"evidenceDelivery"`
}
32 changes: 20 additions & 12 deletions internal/app/donor_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,17 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocuments(t *testing.T) {
FeeType: pay.HalfFee,
Tasks: page.Tasks{PayForLpa: actor.PaymentTaskPending},
HasSentApplicationUpdatedEvent: true,
EvidenceDelivery: pay.Upload,
}).
Return(nil)

eventClient := newMockEventClient(t)
eventClient.
On("Send", ctx, "reduced-fee-requested", reducedFeeRequestedEvent{
UID: "M-1111",
RequestType: "HalfFee",
Evidence: []string{"lpa-uid-evidence-a-uid"},
UID: "M-1111",
RequestType: "HalfFee",
Evidence: []string{"lpa-uid-evidence-a-uid"},
EvidenceDelivery: "upload",
}).
Return(nil)

Expand All @@ -517,6 +519,7 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocuments(t *testing.T) {
FeeType: pay.HalfFee,
Tasks: page.Tasks{PayForLpa: actor.PaymentTaskPending},
HasSentApplicationUpdatedEvent: true,
EvidenceDelivery: pay.Upload,
})

assert.Nil(t, err)
Expand Down Expand Up @@ -591,9 +594,10 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocumentsWhenEventClientSe
eventClient := newMockEventClient(t)
eventClient.
On("Send", ctx, "reduced-fee-requested", reducedFeeRequestedEvent{
UID: "M-1111",
RequestType: "HalfFee",
Evidence: []string{"lpa-uid-evidence-a-uid"},
UID: "M-1111",
RequestType: "HalfFee",
Evidence: []string{"lpa-uid-evidence-a-uid"},
EvidenceDelivery: "upload",
}).
Return(expectedError)

Expand Down Expand Up @@ -623,6 +627,7 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocumentsWhenEventClientSe
FeeType: pay.HalfFee,
Tasks: page.Tasks{PayForLpa: actor.PaymentTaskPending},
HasSentApplicationUpdatedEvent: true,
EvidenceDelivery: pay.Upload,
})

assert.Nil(t, err)
Expand All @@ -635,9 +640,10 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocumentsWhenDocumentStore
eventClient := newMockEventClient(t)
eventClient.
On("Send", ctx, "reduced-fee-requested", reducedFeeRequestedEvent{
UID: "M-1111",
RequestType: "HalfFee",
Evidence: []string{"lpa-uid-evidence-a-uid"},
UID: "M-1111",
RequestType: "HalfFee",
Evidence: []string{"lpa-uid-evidence-a-uid"},
EvidenceDelivery: "upload",
}).
Return(nil)

Expand Down Expand Up @@ -670,6 +676,7 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocumentsWhenDocumentStore
FeeType: pay.HalfFee,
Tasks: page.Tasks{PayForLpa: actor.PaymentTaskPending},
HasSentApplicationUpdatedEvent: true,
EvidenceDelivery: pay.Upload,
})

assert.Nil(t, err)
Expand Down Expand Up @@ -859,9 +866,10 @@ func TestEventSchema(t *testing.T) {
},
},
"reduced-fee-requested": reducedFeeRequestedEvent{
UID: "M-0000-0000-0000",
RequestType: "NoFee",
Evidence: []string{"key"},
UID: "M-0000-0000-0000",
RequestType: "NoFee",
Evidence: []string{"key"},
EvidenceDelivery: "upload",
},
}

Expand Down
7 changes: 6 additions & 1 deletion internal/app/testdata/reduced-fee-requested.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
"items": {
"type": "string"
}
},
"evidenceDelivery": {
"type": "string",
"description": "How the evidence is being delivered to OPG",
"enum": ["upload", "post"]
}
},
"required": ["uid", "requestType", "evidence"]
"required": ["uid", "requestType", "evidence", "evidenceDelivery"]
}

0 comments on commit c0de457

Please sign in to comment.