Skip to content

Commit

Permalink
Rename donordata Provided and Tasks (#1395)
Browse files Browse the repository at this point in the history
* Rename donordata Provided and Tasks
* Move tasks from using actor
* Move uses of actor.ShareCodeData to sharecode.Data
  • Loading branch information
hawx authored Aug 2, 2024
1 parent 4293ce7 commit 955c002
Show file tree
Hide file tree
Showing 292 changed files with 2,591 additions and 2,601 deletions.
4 changes: 2 additions & 2 deletions cmd/event-received/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type LambdaClient interface {
}

type LpaStoreClient interface {
SendLpa(ctx context.Context, donor *donordata.DonorProvidedDetails) error
SendLpa(ctx context.Context, donor *donordata.Provided) error
Lpa(ctx context.Context, uid string) (*lpastore.Lpa, error)
}

Expand All @@ -38,7 +38,7 @@ type SecretsClient interface {

type ShareCodeSender interface {
SendCertificateProviderInvite(context.Context, page.AppData, page.CertificateProviderInvite) error
SendCertificateProviderPrompt(context.Context, page.AppData, *donordata.DonorProvidedDetails) error
SendCertificateProviderPrompt(context.Context, page.AppData, *donordata.Provided) error
SendAttorneys(context.Context, page.AppData, *lpastore.Lpa) error
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/event-received/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func handleObjectTagsAdded(ctx context.Context, dynamodbClient dynamodbClient, e
return nil
}

func putDonor(ctx context.Context, donor *donordata.DonorProvidedDetails, now func() time.Time, client dynamodbClient) error {
func putDonor(ctx context.Context, donor *donordata.Provided, now func() time.Time, client dynamodbClient) error {
donor.UpdatedAt = now()
if err := donor.UpdateHash(); err != nil {
return err
Expand All @@ -61,7 +61,7 @@ func putDonor(ctx context.Context, donor *donordata.DonorProvidedDetails, now fu
return client.Put(ctx, donor)
}

func getDonorByLpaUID(ctx context.Context, client dynamodbClient, uid string) (*donordata.DonorProvidedDetails, error) {
func getDonorByLpaUID(ctx context.Context, client dynamodbClient, uid string) (*donordata.Provided, error) {
var key dynamo.Keys
if err := client.OneByUID(ctx, uid, &key); err != nil {
return nil, fmt.Errorf("failed to resolve uid: %w", err)
Expand All @@ -71,7 +71,7 @@ func getDonorByLpaUID(ctx context.Context, client dynamodbClient, uid string) (*
return nil, fmt.Errorf("PK missing from LPA in response")
}

var donor donordata.DonorProvidedDetails
var donor donordata.Provided
if err := client.One(ctx, key.PK, key.SK, &donor); err != nil {
return nil, fmt.Errorf("failed to get LPA: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/event-received/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestHandleObjectTagsAdded(t *testing.T) {
dynamoClient.
On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything).
Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error {
b, _ := json.Marshal(donordata.DonorProvidedDetails{LpaID: "123", Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}})
b, _ := json.Marshal(donordata.Provided{LpaID: "123", Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}})
json.Unmarshal(b, v)
return nil
})
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestHandleObjectTagsAddedWhenDynamoClientOneByUIDError(t *testing.T) {
dynamoClient.
On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything).
Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error {
b, _ := json.Marshal(donordata.DonorProvidedDetails{LpaID: "123", Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}})
b, _ := json.Marshal(donordata.Provided{LpaID: "123", Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}})
json.Unmarshal(b, v)
return expectedError
})
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestHandleObjectTagsAddedWhenDocumentStoreUpdateScanResultsError(t *testing
dynamoClient.
On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything).
Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error {
b, _ := json.Marshal(donordata.DonorProvidedDetails{LpaID: "123", Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}})
b, _ := json.Marshal(donordata.Provided{LpaID: "123", Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}})
json.Unmarshal(b, v)
return nil
})
Expand All @@ -184,7 +184,7 @@ func TestHandleObjectTagsAddedWhenDocumentStoreUpdateScanResultsError(t *testing
}

func TestGetLpaByUID(t *testing.T) {
expectedDonor := &donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}
expectedDonor := &donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}

client := newMockDynamodbClient(t)
client.
Expand Down
10 changes: 5 additions & 5 deletions cmd/event-received/lpastore_event_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdated(t *testing.T) {
Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`),
}

updated := &donordata.DonorProvidedDetails{
updated := &donordata.Provided{
PK: dynamo.LpaKey("123"),
SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")),
PerfectAt: testNow,
Expand All @@ -45,7 +45,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdated(t *testing.T) {
client.
On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything).
Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error {
b, _ := json.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))})
b, _ := json.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))})
json.Unmarshal(b, v)
return nil
})
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdatedWhenDynamoGetErrors(t *testing.T) {
Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`),
}

updated := &donordata.DonorProvidedDetails{
updated := &donordata.Provided{
PK: dynamo.LpaKey("123"),
SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")),
PerfectAt: testNow,
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdatedWhenDynamoPutErrors(t *testing.T) {
Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`),
}

updated := &donordata.DonorProvidedDetails{
updated := &donordata.Provided{
PK: dynamo.LpaKey("123"),
SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")),
PerfectAt: testNow,
Expand All @@ -133,7 +133,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdatedWhenDynamoPutErrors(t *testing.T) {
client.
On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything).
Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error {
b, _ := json.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))})
b, _ := json.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))})
json.Unmarshal(b, v)
return nil
})
Expand Down
4 changes: 2 additions & 2 deletions cmd/event-received/makeregister_event_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestHandleUidRequested(t *testing.T) {
dynamoClient.
On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything).
Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error {
b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{
b, _ := attributevalue.Marshal(&donordata.Provided{
Donor: donordata.Donor{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "a"}, DateOfBirth: dob},
Type: donordata.LpaTypePersonalWelfare,
CreatedAt: testNow,
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestHandleUidRequestedWhenEventClientErrors(t *testing.T) {
dynamoClient.
On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything).
Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error {
b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{})
b, _ := attributevalue.Marshal(&donordata.Provided{})
attributevalue.Unmarshal(b, v)
return nil
})
Expand Down
10 changes: 5 additions & 5 deletions cmd/event-received/mock_lpaStoreClient_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions cmd/event-received/mock_shareCodeSender_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/event-received/sirius_event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func handleDonorSubmissionCompleted(ctx context.Context, client dynamodbClient,

lpaID := uuidString()

if err := client.Put(ctx, &donordata.DonorProvidedDetails{
if err := client.Put(ctx, &donordata.Provided{
PK: dynamo.LpaKey(lpaID),
SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")),
LpaID: lpaID,
Expand Down
Loading

0 comments on commit 955c002

Please sign in to comment.