From 53833f59674961b8c980dd31a0188012b03a9dd5 Mon Sep 17 00:00:00 2001 From: Joshua Hawxwell Date: Mon, 5 Aug 2024 11:34:50 +0100 Subject: [PATCH] Move supporter related code to packages (#1403) * Move supporter pages to new package * Move supporter related stores * Move supporter types to data package and stores to supporter * Remove unused mocks * Move NoVoucherDecision to donordata --- .mockery.yaml | 4 +- cmd/event-received/mock_store_test.go | 96 ----- internal/actor/organisation.go | 83 ---- internal/app/app.go | 12 +- internal/app/mock_DocumentStore_test.go | 191 --------- internal/app/mock_EventClient_test.go | 225 ----------- .../mock_ShareCodeStoreDynamoClient_test.go | 277 ------------- internal/app/mock_UidClient_test.go | 94 ----- internal/appcontext/data.go | 3 +- internal/appcontext/data_test.go | 3 +- .../mock_CertificateProviderStore_test.go | 96 ----- .../attorneypage/mock_DonorStore_test.go | 95 ----- .../donordata}/enum_novoucherdecision.go | 2 +- .../donor/donordata/mock_Localizer_test.go | 172 -------- .../donordata}/no_voucher_decision.go | 2 +- .../donor/donorpage/what_you_can_do_now.go | 19 +- .../donorpage/what_you_can_do_now_test.go | 21 +- internal/dynamo/mock_Logger_test.go | 74 ---- internal/page/fixtures/supporter.go | 23 +- internal/page/mock_AttorneyStore_test.go | 71 ---- internal/page/mock_DataStore_test.go | 85 ---- internal/page/mock_shareCodeEmail_test.go | 83 ---- .../supporter/mock_LpaStoreClient_test.go | 96 ----- internal/{app => supporter}/member_store.go | 75 ++-- .../{app => supporter}/member_store_test.go | 130 +++--- internal/supporter/mock_DynamoClient_test.go | 373 ++++++++++++++++++ internal/supporter/mock_test.go | 62 +++ .../{app => supporter}/organisation_store.go | 33 +- .../organisation_store_test.go | 60 +-- .../supporterdata}/enum_permission.go | 2 +- .../supporterdata}/enum_status.go | 2 +- internal/supporter/supporterdata/member.go | 35 ++ .../supporter/supporterdata/member_invite.go | 40 ++ .../supporter/supporterdata/organisation.go | 23 ++ .../supporterdata}/organisation_test.go | 2 +- .../supporterdata}/permission.go | 2 +- .../supporterdata}/status.go | 2 +- .../confirm_donor_can_interact_online.go | 6 +- .../confirm_donor_can_interact_online_test.go | 12 +- .../supporterpage}/dashboard.go | 6 +- .../supporterpage}/dashboard_test.go | 2 +- .../supporterpage}/delete_organisation.go | 6 +- .../delete_organisation_test.go | 18 +- .../supporterpage}/donor_access.go | 6 +- .../supporterpage}/donor_access_test.go | 24 +- .../supporterpage}/edit_member.go | 26 +- .../supporterpage}/edit_member_test.go | 104 ++--- .../supporterpage}/edit_organisation_name.go | 6 +- .../edit_organisation_name_test.go | 16 +- .../supporterpage}/enter_organisation_name.go | 2 +- .../enter_organisation_name_test.go | 18 +- .../supporterpage}/enter_reference_number.go | 2 +- .../enter_reference_number_test.go | 18 +- .../supporterpage}/enter_your_name.go | 2 +- .../supporterpage}/enter_your_name_test.go | 6 +- .../supporterpage}/guidance.go | 8 +- .../supporterpage}/guidance_test.go | 2 +- .../supporterpage}/invite_member.go | 16 +- .../supporterpage}/invite_member_test.go | 28 +- .../supporterpage}/login_callback.go | 2 +- .../supporterpage}/login_callback_test.go | 36 +- .../supporterpage}/manage_team_members.go | 12 +- .../manage_team_members_test.go | 38 +- .../mock_CertificateProviderStore_test.go | 2 +- .../supporterpage}/mock_DonorStore_test.go | 2 +- .../supporterpage}/mock_ErrorHandler_test.go | 2 +- .../supporterpage}/mock_Handler_test.go | 23 +- .../supporterpage}/mock_Localizer_test.go | 2 +- .../supporterpage}/mock_Logger_test.go | 2 +- .../mock_LoginCallbackOneLoginClient_test.go | 2 +- .../mock_LpaStoreResolvingService_test.go | 2 +- .../supporterpage}/mock_MemberStore_test.go | 155 ++++---- .../supporterpage}/mock_NotifyClient_test.go | 2 +- .../mock_OneLoginClient_test.go | 2 +- .../mock_OrganisationStore_test.go | 67 ++-- .../mock_ProgressTracker_test.go | 2 +- .../supporterpage}/mock_SearchClient_test.go | 2 +- .../supporterpage}/mock_SessionStore_test.go | 2 +- .../mock_ShareCodeStore_test.go | 2 +- .../supporterpage}/mock_SupporterPath_test.go | 2 +- .../supporterpage}/mock_Template_test.go | 2 +- .../supporterpage}/mock_test.go | 6 +- .../supporterpage}/register.go | 36 +- .../supporterpage}/register_test.go | 58 +-- .../supporterpage}/view_lpa.go | 6 +- .../supporterpage}/view_lpa_test.go | 10 +- internal/uid/mock_v4Signer_test.go | 58 --- 87 files changed, 1153 insertions(+), 2386 deletions(-) delete mode 100644 cmd/event-received/mock_store_test.go delete mode 100644 internal/actor/organisation.go delete mode 100644 internal/app/mock_DocumentStore_test.go delete mode 100644 internal/app/mock_EventClient_test.go delete mode 100644 internal/app/mock_ShareCodeStoreDynamoClient_test.go delete mode 100644 internal/app/mock_UidClient_test.go delete mode 100644 internal/attorney/attorneypage/mock_CertificateProviderStore_test.go delete mode 100644 internal/attorney/attorneypage/mock_DonorStore_test.go rename internal/{actor => donor/donordata}/enum_novoucherdecision.go (99%) delete mode 100644 internal/donor/donordata/mock_Localizer_test.go rename internal/{actor => donor/donordata}/no_voucher_decision.go (95%) delete mode 100644 internal/dynamo/mock_Logger_test.go delete mode 100644 internal/page/mock_AttorneyStore_test.go delete mode 100644 internal/page/mock_DataStore_test.go delete mode 100644 internal/page/mock_shareCodeEmail_test.go delete mode 100644 internal/page/supporter/mock_LpaStoreClient_test.go rename internal/{app => supporter}/member_store.go (70%) rename internal/{app => supporter}/member_store_test.go (80%) create mode 100644 internal/supporter/mock_DynamoClient_test.go create mode 100644 internal/supporter/mock_test.go rename internal/{app => supporter}/organisation_store.go (71%) rename internal/{app => supporter}/organisation_store_test.go (77%) rename internal/{actor => supporter/supporterdata}/enum_permission.go (98%) rename internal/{actor => supporter/supporterdata}/enum_status.go (98%) create mode 100644 internal/supporter/supporterdata/member.go create mode 100644 internal/supporter/supporterdata/member_invite.go create mode 100644 internal/supporter/supporterdata/organisation.go rename internal/{actor => supporter/supporterdata}/organisation_test.go (96%) rename internal/{actor => supporter/supporterdata}/permission.go (89%) rename internal/{actor => supporter/supporterdata}/status.go (89%) rename internal/{page/supporter => supporter/supporterpage}/confirm_donor_can_interact_online.go (86%) rename internal/{page/supporter => supporter/supporterpage}/confirm_donor_can_interact_online_test.go (91%) rename internal/{page/supporter => supporter/supporterpage}/dashboard.go (87%) rename internal/{page/supporter => supporter/supporterpage}/dashboard_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/delete_organisation.go (88%) rename internal/{page/supporter => supporter/supporterpage}/delete_organisation_test.go (87%) rename internal/{page/supporter => supporter/supporterpage}/donor_access.go (95%) rename internal/{page/supporter => supporter/supporterpage}/donor_access_test.go (92%) rename internal/{page/supporter => supporter/supporterpage}/edit_member.go (82%) rename internal/{page/supporter => supporter/supporterpage}/edit_member_test.go (80%) rename internal/{page/supporter => supporter/supporterpage}/edit_organisation_name.go (85%) rename internal/{page/supporter => supporter/supporterpage}/edit_organisation_name_test.go (88%) rename internal/{page/supporter => supporter/supporterpage}/enter_organisation_name.go (99%) rename internal/{page/supporter => supporter/supporterpage}/enter_organisation_name_test.go (94%) rename internal/{page/supporter => supporter/supporterpage}/enter_reference_number.go (99%) rename internal/{page/supporter => supporter/supporterpage}/enter_reference_number_test.go (95%) rename internal/{page/supporter => supporter/supporterpage}/enter_your_name.go (98%) rename internal/{page/supporter => supporter/supporterpage}/enter_your_name_test.go (96%) rename internal/{page/supporter => supporter/supporterpage}/guidance.go (71%) rename internal/{page/supporter => supporter/supporterpage}/guidance_test.go (97%) rename internal/{page/supporter => supporter/supporterpage}/invite_member.go (82%) rename internal/{page/supporter => supporter/supporterpage}/invite_member_test.go (89%) rename internal/{page/supporter => supporter/supporterpage}/login_callback.go (99%) rename internal/{page/supporter => supporter/supporterpage}/login_callback_test.go (94%) rename internal/{page/supporter => supporter/supporterpage}/manage_team_members.go (87%) rename internal/{page/supporter => supporter/supporterpage}/manage_team_members_test.go (82%) rename internal/{page/supporter => supporter/supporterpage}/mock_CertificateProviderStore_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_DonorStore_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_ErrorHandler_test.go (98%) rename internal/{page/supporter => supporter/supporterpage}/mock_Handler_test.go (74%) rename internal/{page/supporter => supporter/supporterpage}/mock_Localizer_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_Logger_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_LoginCallbackOneLoginClient_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_LpaStoreResolvingService_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_MemberStore_test.go (74%) rename internal/{page/supporter => supporter/supporterpage}/mock_NotifyClient_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_OneLoginClient_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_OrganisationStore_test.go (74%) rename internal/{page/supporter => supporter/supporterpage}/mock_ProgressTracker_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_SearchClient_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_SessionStore_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_ShareCodeStore_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_SupporterPath_test.go (99%) rename internal/{page/supporter => supporter/supporterpage}/mock_Template_test.go (98%) rename internal/{page/supporter => supporter/supporterpage}/mock_test.go (81%) rename internal/{page/supporter => supporter/supporterpage}/register.go (88%) rename internal/{page/supporter => supporter/supporterpage}/register_test.go (89%) rename internal/{page/supporter => supporter/supporterpage}/view_lpa.go (82%) rename internal/{page/supporter => supporter/supporterpage}/view_lpa_test.go (88%) delete mode 100644 internal/uid/mock_v4Signer_test.go diff --git a/.mockery.yaml b/.mockery.yaml index 6564fb7926..048f703e3e 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -21,7 +21,6 @@ packages: github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore: github.com/ministryofjustice/opg-modernising-lpa/internal/notify: github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin: - github.com/ministryofjustice/opg-modernising-lpa/internal/page/supporter: github.com/ministryofjustice/opg-modernising-lpa/internal/page: github.com/ministryofjustice/opg-modernising-lpa/internal/pay: github.com/ministryofjustice/opg-modernising-lpa/internal/place: @@ -30,5 +29,8 @@ packages: github.com/ministryofjustice/opg-modernising-lpa/internal/secrets: github.com/ministryofjustice/opg-modernising-lpa/internal/sesh: github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode: + github.com/ministryofjustice/opg-modernising-lpa/internal/supporter: + github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata: + github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterpage: github.com/ministryofjustice/opg-modernising-lpa/internal/uid: github.com/ministryofjustice/opg-modernising-lpa/internal/validation: diff --git a/cmd/event-received/mock_store_test.go b/cmd/event-received/mock_store_test.go deleted file mode 100644 index 61d59ba43f..0000000000 --- a/cmd/event-received/mock_store_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. - -package main - -import ( - context "context" - - dynamodb "github.com/aws/aws-sdk-go-v2/service/dynamodb" - mock "github.com/stretchr/testify/mock" -) - -// mockStore is an autogenerated mock type for the store type -type mockStore struct { - mock.Mock -} - -// PutItem provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockStore) PutItem(_a0 context.Context, _a1 *dynamodb.PutItemInput, _a2 ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error) { - _va := make([]interface{}, len(_a2)) - for _i := range _a2 { - _va[_i] = _a2[_i] - } - var _ca []interface{} - _ca = append(_ca, _a0, _a1) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *dynamodb.PutItemOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *dynamodb.PutItemInput, ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)); ok { - return rf(_a0, _a1, _a2...) - } - if rf, ok := ret.Get(0).(func(context.Context, *dynamodb.PutItemInput, ...func(*dynamodb.Options)) *dynamodb.PutItemOutput); ok { - r0 = rf(_a0, _a1, _a2...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dynamodb.PutItemOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *dynamodb.PutItemInput, ...func(*dynamodb.Options)) error); ok { - r1 = rf(_a0, _a1, _a2...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Query provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockStore) Query(_a0 context.Context, _a1 *dynamodb.QueryInput, _a2 ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error) { - _va := make([]interface{}, len(_a2)) - for _i := range _a2 { - _va[_i] = _a2[_i] - } - var _ca []interface{} - _ca = append(_ca, _a0, _a1) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *dynamodb.QueryOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *dynamodb.QueryInput, ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)); ok { - return rf(_a0, _a1, _a2...) - } - if rf, ok := ret.Get(0).(func(context.Context, *dynamodb.QueryInput, ...func(*dynamodb.Options)) *dynamodb.QueryOutput); ok { - r0 = rf(_a0, _a1, _a2...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dynamodb.QueryOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *dynamodb.QueryInput, ...func(*dynamodb.Options)) error); ok { - r1 = rf(_a0, _a1, _a2...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTnewMockStore interface { - mock.TestingT - Cleanup(func()) -} - -// newMockStore creates a new instance of mockStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func newMockStore(t mockConstructorTestingTnewMockStore) *mockStore { - mock := &mockStore{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/actor/organisation.go b/internal/actor/organisation.go deleted file mode 100644 index 8fb60ded6d..0000000000 --- a/internal/actor/organisation.go +++ /dev/null @@ -1,83 +0,0 @@ -package actor - -import ( - "fmt" - "time" - - "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" -) - -const memberInviteExpireAfter = time.Hour * 48 - -// An Organisation contains users associated with a set of permissions that work on the -// same set of LPAs. -type Organisation struct { - PK, SK dynamo.OrganisationKeyType - // CreatedAt is when the Organisation was created - CreatedAt time.Time - // UpdatedAt is when the Organisation was last updated - UpdatedAt time.Time - // DeletedAt is when the Organisation was (soft) deleted - DeletedAt time.Time - // ID is a unique identifier for the Organisation - ID string - // Name of the Organisation, this is unique across all Organisations - Name string -} - -// A Member is the association of a OneLogin user with an Organisation. -type Member struct { - PK dynamo.OrganisationKeyType - SK dynamo.MemberKeyType - // CreatedAt is when the Member was created - CreatedAt time.Time - // UpdatedAt is when the Member was last updated - UpdatedAt time.Time - // ID is a unique identifier for the Member - ID string - // OrganisationID identifies the organisation the member belongs to - OrganisationID string - Email string - FirstNames string - LastName string - // Permission is the type of permissions assigned to the member to set available actions in an Organisation - Permission Permission - // Status controls access to the Organisation - Status Status - // LastLoggedInAt is when the Member last logged in to the service - LastLoggedInAt time.Time -} - -func (i Member) FullName() string { - return fmt.Sprintf("%s %s", i.FirstNames, i.LastName) -} - -// A MemberInvite is created to allow a new Member to join an Organisation -type MemberInvite struct { - PK dynamo.OrganisationKeyType - SK dynamo.MemberInviteKeyType - // CreatedAt is when the MemberInvite was created - CreatedAt time.Time - // UpdatedAt is when the MemberInvite was last updated - UpdatedAt time.Time - // OrganisationID identifies the organisation the invite is for - OrganisationID string - // OrganisationName is the name of the organisation the invite is for - OrganisationName string - // Email is the address the new Member must sign in as for the invite - Email string - FirstNames string - LastName string - // Permission is the type of permissions assigned to the member to set available actions in an Organisation - Permission Permission - // ReferenceNumber is a unique code used to invite a Member to and Organisation - ReferenceNumber string -} - -func (i MemberInvite) HasExpired() bool { - return i.CreatedAt.Add(memberInviteExpireAfter).Before(time.Now()) -} - -func (i MemberInvite) FullName() string { - return fmt.Sprintf("%s %s", i.FirstNames, i.LastName) -} diff --git a/internal/app/app.go b/internal/app/app.go index e9b0cbaa02..abc6489443 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -6,12 +6,9 @@ import ( "log/slog" "net/http" "strings" - "time" dynamodbtypes "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" - "github.com/google/uuid" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneypage" @@ -28,13 +25,14 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/page/fixtures" - "github.com/ministryofjustice/opg-modernising-lpa/internal/page/supporter" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterpage" ) type ErrorHandler func(http.ResponseWriter, *http.Request, error) @@ -102,8 +100,8 @@ func App( shareCodeStore := sharecode.NewStore(lpaDynamoClient) dashboardStore := &dashboardStore{dynamoClient: lpaDynamoClient, lpaStoreResolvingService: lpastore.NewResolvingService(donorStore, lpaStoreClient)} evidenceReceivedStore := &evidenceReceivedStore{dynamoClient: lpaDynamoClient} - organisationStore := &organisationStore{dynamoClient: lpaDynamoClient, now: time.Now, uuidString: uuid.NewString, newUID: actoruid.New} - memberStore := &memberStore{dynamoClient: lpaDynamoClient, now: time.Now, uuidString: uuid.NewString} + organisationStore := supporter.NewOrganisationStore(lpaDynamoClient) + memberStore := supporter.NewMemberStore(lpaDynamoClient) progressTracker := page.ProgressTracker{Localizer: localizer} shareCodeSender := page.NewShareCodeSender(shareCodeStore, notifyClient, appPublicURL, random.String, eventClient) @@ -147,7 +145,7 @@ func App( handleRoot(page.Paths.LpaWithdrawn, RequireSession, page.Guidance(tmpls.Get("lpa_withdrawn.gohtml"))) - supporter.Register( + supporterpage.Register( rootMux, logger, supporterTmpls, diff --git a/internal/app/mock_DocumentStore_test.go b/internal/app/mock_DocumentStore_test.go deleted file mode 100644 index d3d97d4ce5..0000000000 --- a/internal/app/mock_DocumentStore_test.go +++ /dev/null @@ -1,191 +0,0 @@ -// Code generated by mockery v2.42.2. DO NOT EDIT. - -package app - -import ( - context "context" - - "github.com/ministryofjustice/opg-modernising-lpa/internal/document" - mock "github.com/stretchr/testify/mock" -) - -// mockDocumentStore is an autogenerated mock type for the DocumentStore type -type mockDocumentStore struct { - mock.Mock -} - -type mockDocumentStore_Expecter struct { - mock *mock.Mock -} - -func (_m *mockDocumentStore) EXPECT() *mockDocumentStore_Expecter { - return &mockDocumentStore_Expecter{mock: &_m.Mock} -} - -// GetAll provides a mock function with given fields: _a0 -func (_m *mockDocumentStore) GetAll(_a0 context.Context) (document.Documents, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for GetAll") - } - - var r0 document.Documents - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (document.Documents, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(context.Context) document.Documents); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(document.Documents) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockDocumentStore_GetAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAll' -type mockDocumentStore_GetAll_Call struct { - *mock.Call -} - -// GetAll is a helper method to define mock.On call -// - _a0 context.Context -func (_e *mockDocumentStore_Expecter) GetAll(_a0 interface{}) *mockDocumentStore_GetAll_Call { - return &mockDocumentStore_GetAll_Call{Call: _e.mock.On("GetAll", _a0)} -} - -func (_c *mockDocumentStore_GetAll_Call) Run(run func(_a0 context.Context)) *mockDocumentStore_GetAll_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *mockDocumentStore_GetAll_Call) Return(_a0 document.Documents, _a1 error) *mockDocumentStore_GetAll_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockDocumentStore_GetAll_Call) RunAndReturn(run func(context.Context) (document.Documents, error)) *mockDocumentStore_GetAll_Call { - _c.Call.Return(run) - return _c -} - -// Put provides a mock function with given fields: _a0, _a1 -func (_m *mockDocumentStore) Put(_a0 context.Context, _a1 document.Document) error { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for Put") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, document.Document) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockDocumentStore_Put_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Put' -type mockDocumentStore_Put_Call struct { - *mock.Call -} - -// Put is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 document.Document -func (_e *mockDocumentStore_Expecter) Put(_a0 interface{}, _a1 interface{}) *mockDocumentStore_Put_Call { - return &mockDocumentStore_Put_Call{Call: _e.mock.On("Put", _a0, _a1)} -} - -func (_c *mockDocumentStore_Put_Call) Run(run func(_a0 context.Context, _a1 document.Document)) *mockDocumentStore_Put_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(document.Document)) - }) - return _c -} - -func (_c *mockDocumentStore_Put_Call) Return(_a0 error) *mockDocumentStore_Put_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockDocumentStore_Put_Call) RunAndReturn(run func(context.Context, document.Document) error) *mockDocumentStore_Put_Call { - _c.Call.Return(run) - return _c -} - -// UpdateScanResults provides a mock function with given fields: _a0, _a1, _a2, _a3 -func (_m *mockDocumentStore) UpdateScanResults(_a0 context.Context, _a1 string, _a2 string, _a3 bool) error { - ret := _m.Called(_a0, _a1, _a2, _a3) - - if len(ret) == 0 { - panic("no return value specified for UpdateScanResults") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, bool) error); ok { - r0 = rf(_a0, _a1, _a2, _a3) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockDocumentStore_UpdateScanResults_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateScanResults' -type mockDocumentStore_UpdateScanResults_Call struct { - *mock.Call -} - -// UpdateScanResults is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 string -// - _a2 string -// - _a3 bool -func (_e *mockDocumentStore_Expecter) UpdateScanResults(_a0 interface{}, _a1 interface{}, _a2 interface{}, _a3 interface{}) *mockDocumentStore_UpdateScanResults_Call { - return &mockDocumentStore_UpdateScanResults_Call{Call: _e.mock.On("UpdateScanResults", _a0, _a1, _a2, _a3)} -} - -func (_c *mockDocumentStore_UpdateScanResults_Call) Run(run func(_a0 context.Context, _a1 string, _a2 string, _a3 bool)) *mockDocumentStore_UpdateScanResults_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(bool)) - }) - return _c -} - -func (_c *mockDocumentStore_UpdateScanResults_Call) Return(_a0 error) *mockDocumentStore_UpdateScanResults_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockDocumentStore_UpdateScanResults_Call) RunAndReturn(run func(context.Context, string, string, bool) error) *mockDocumentStore_UpdateScanResults_Call { - _c.Call.Return(run) - return _c -} - -// newMockDocumentStore creates a new instance of mockDocumentStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockDocumentStore(t interface { - mock.TestingT - Cleanup(func()) -}) *mockDocumentStore { - mock := &mockDocumentStore{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/app/mock_EventClient_test.go b/internal/app/mock_EventClient_test.go deleted file mode 100644 index b64892c7da..0000000000 --- a/internal/app/mock_EventClient_test.go +++ /dev/null @@ -1,225 +0,0 @@ -// Code generated by mockery v2.42.2. DO NOT EDIT. - -package app - -import ( - context "context" - - event "github.com/ministryofjustice/opg-modernising-lpa/internal/event" - mock "github.com/stretchr/testify/mock" -) - -// mockEventClient is an autogenerated mock type for the EventClient type -type mockEventClient struct { - mock.Mock -} - -type mockEventClient_Expecter struct { - mock *mock.Mock -} - -func (_m *mockEventClient) EXPECT() *mockEventClient_Expecter { - return &mockEventClient_Expecter{mock: &_m.Mock} -} - -// SendApplicationUpdated provides a mock function with given fields: _a0, _a1 -func (_m *mockEventClient) SendApplicationUpdated(_a0 context.Context, _a1 event.ApplicationUpdated) error { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for SendApplicationUpdated") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, event.ApplicationUpdated) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockEventClient_SendApplicationUpdated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendApplicationUpdated' -type mockEventClient_SendApplicationUpdated_Call struct { - *mock.Call -} - -// SendApplicationUpdated is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 event.ApplicationUpdated -func (_e *mockEventClient_Expecter) SendApplicationUpdated(_a0 interface{}, _a1 interface{}) *mockEventClient_SendApplicationUpdated_Call { - return &mockEventClient_SendApplicationUpdated_Call{Call: _e.mock.On("SendApplicationUpdated", _a0, _a1)} -} - -func (_c *mockEventClient_SendApplicationUpdated_Call) Run(run func(_a0 context.Context, _a1 event.ApplicationUpdated)) *mockEventClient_SendApplicationUpdated_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(event.ApplicationUpdated)) - }) - return _c -} - -func (_c *mockEventClient_SendApplicationUpdated_Call) Return(_a0 error) *mockEventClient_SendApplicationUpdated_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockEventClient_SendApplicationUpdated_Call) RunAndReturn(run func(context.Context, event.ApplicationUpdated) error) *mockEventClient_SendApplicationUpdated_Call { - _c.Call.Return(run) - return _c -} - -// SendPreviousApplicationLinked provides a mock function with given fields: _a0, _a1 -func (_m *mockEventClient) SendPreviousApplicationLinked(_a0 context.Context, _a1 event.PreviousApplicationLinked) error { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for SendPreviousApplicationLinked") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, event.PreviousApplicationLinked) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockEventClient_SendPreviousApplicationLinked_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendPreviousApplicationLinked' -type mockEventClient_SendPreviousApplicationLinked_Call struct { - *mock.Call -} - -// SendPreviousApplicationLinked is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 event.PreviousApplicationLinked -func (_e *mockEventClient_Expecter) SendPreviousApplicationLinked(_a0 interface{}, _a1 interface{}) *mockEventClient_SendPreviousApplicationLinked_Call { - return &mockEventClient_SendPreviousApplicationLinked_Call{Call: _e.mock.On("SendPreviousApplicationLinked", _a0, _a1)} -} - -func (_c *mockEventClient_SendPreviousApplicationLinked_Call) Run(run func(_a0 context.Context, _a1 event.PreviousApplicationLinked)) *mockEventClient_SendPreviousApplicationLinked_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(event.PreviousApplicationLinked)) - }) - return _c -} - -func (_c *mockEventClient_SendPreviousApplicationLinked_Call) Return(_a0 error) *mockEventClient_SendPreviousApplicationLinked_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockEventClient_SendPreviousApplicationLinked_Call) RunAndReturn(run func(context.Context, event.PreviousApplicationLinked) error) *mockEventClient_SendPreviousApplicationLinked_Call { - _c.Call.Return(run) - return _c -} - -// SendReducedFeeRequested provides a mock function with given fields: _a0, _a1 -func (_m *mockEventClient) SendReducedFeeRequested(_a0 context.Context, _a1 event.ReducedFeeRequested) error { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for SendReducedFeeRequested") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, event.ReducedFeeRequested) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockEventClient_SendReducedFeeRequested_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendReducedFeeRequested' -type mockEventClient_SendReducedFeeRequested_Call struct { - *mock.Call -} - -// SendReducedFeeRequested is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 event.ReducedFeeRequested -func (_e *mockEventClient_Expecter) SendReducedFeeRequested(_a0 interface{}, _a1 interface{}) *mockEventClient_SendReducedFeeRequested_Call { - return &mockEventClient_SendReducedFeeRequested_Call{Call: _e.mock.On("SendReducedFeeRequested", _a0, _a1)} -} - -func (_c *mockEventClient_SendReducedFeeRequested_Call) Run(run func(_a0 context.Context, _a1 event.ReducedFeeRequested)) *mockEventClient_SendReducedFeeRequested_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(event.ReducedFeeRequested)) - }) - return _c -} - -func (_c *mockEventClient_SendReducedFeeRequested_Call) Return(_a0 error) *mockEventClient_SendReducedFeeRequested_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockEventClient_SendReducedFeeRequested_Call) RunAndReturn(run func(context.Context, event.ReducedFeeRequested) error) *mockEventClient_SendReducedFeeRequested_Call { - _c.Call.Return(run) - return _c -} - -// SendUidRequested provides a mock function with given fields: _a0, _a1 -func (_m *mockEventClient) SendUidRequested(_a0 context.Context, _a1 event.UidRequested) error { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for SendUidRequested") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, event.UidRequested) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockEventClient_SendUidRequested_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendUidRequested' -type mockEventClient_SendUidRequested_Call struct { - *mock.Call -} - -// SendUidRequested is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 event.UidRequested -func (_e *mockEventClient_Expecter) SendUidRequested(_a0 interface{}, _a1 interface{}) *mockEventClient_SendUidRequested_Call { - return &mockEventClient_SendUidRequested_Call{Call: _e.mock.On("SendUidRequested", _a0, _a1)} -} - -func (_c *mockEventClient_SendUidRequested_Call) Run(run func(_a0 context.Context, _a1 event.UidRequested)) *mockEventClient_SendUidRequested_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(event.UidRequested)) - }) - return _c -} - -func (_c *mockEventClient_SendUidRequested_Call) Return(_a0 error) *mockEventClient_SendUidRequested_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockEventClient_SendUidRequested_Call) RunAndReturn(run func(context.Context, event.UidRequested) error) *mockEventClient_SendUidRequested_Call { - _c.Call.Return(run) - return _c -} - -// newMockEventClient creates a new instance of mockEventClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockEventClient(t interface { - mock.TestingT - Cleanup(func()) -}) *mockEventClient { - mock := &mockEventClient{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/app/mock_ShareCodeStoreDynamoClient_test.go b/internal/app/mock_ShareCodeStoreDynamoClient_test.go deleted file mode 100644 index b2bf5c535d..0000000000 --- a/internal/app/mock_ShareCodeStoreDynamoClient_test.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by mockery v2.42.2. DO NOT EDIT. - -package app - -import ( - context "context" - - dynamo "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" - mock "github.com/stretchr/testify/mock" -) - -// mockShareCodeStoreDynamoClient is an autogenerated mock type for the ShareCodeStoreDynamoClient type -type mockShareCodeStoreDynamoClient struct { - mock.Mock -} - -type mockShareCodeStoreDynamoClient_Expecter struct { - mock *mock.Mock -} - -func (_m *mockShareCodeStoreDynamoClient) EXPECT() *mockShareCodeStoreDynamoClient_Expecter { - return &mockShareCodeStoreDynamoClient_Expecter{mock: &_m.Mock} -} - -// DeleteOne provides a mock function with given fields: ctx, pk, sk -func (_m *mockShareCodeStoreDynamoClient) DeleteOne(ctx context.Context, pk dynamo.PK, sk dynamo.SK) error { - ret := _m.Called(ctx, pk, sk) - - if len(ret) == 0 { - panic("no return value specified for DeleteOne") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, dynamo.PK, dynamo.SK) error); ok { - r0 = rf(ctx, pk, sk) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockShareCodeStoreDynamoClient_DeleteOne_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteOne' -type mockShareCodeStoreDynamoClient_DeleteOne_Call struct { - *mock.Call -} - -// DeleteOne is a helper method to define mock.On call -// - ctx context.Context -// - pk dynamo.PK -// - sk dynamo.SK -func (_e *mockShareCodeStoreDynamoClient_Expecter) DeleteOne(ctx interface{}, pk interface{}, sk interface{}) *mockShareCodeStoreDynamoClient_DeleteOne_Call { - return &mockShareCodeStoreDynamoClient_DeleteOne_Call{Call: _e.mock.On("DeleteOne", ctx, pk, sk)} -} - -func (_c *mockShareCodeStoreDynamoClient_DeleteOne_Call) Run(run func(ctx context.Context, pk dynamo.PK, sk dynamo.SK)) *mockShareCodeStoreDynamoClient_DeleteOne_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dynamo.PK), args[2].(dynamo.SK)) - }) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_DeleteOne_Call) Return(_a0 error) *mockShareCodeStoreDynamoClient_DeleteOne_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_DeleteOne_Call) RunAndReturn(run func(context.Context, dynamo.PK, dynamo.SK) error) *mockShareCodeStoreDynamoClient_DeleteOne_Call { - _c.Call.Return(run) - return _c -} - -// One provides a mock function with given fields: ctx, pk, sk, v -func (_m *mockShareCodeStoreDynamoClient) One(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - ret := _m.Called(ctx, pk, sk, v) - - if len(ret) == 0 { - panic("no return value specified for One") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, dynamo.PK, dynamo.SK, interface{}) error); ok { - r0 = rf(ctx, pk, sk, v) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockShareCodeStoreDynamoClient_One_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'One' -type mockShareCodeStoreDynamoClient_One_Call struct { - *mock.Call -} - -// One is a helper method to define mock.On call -// - ctx context.Context -// - pk dynamo.PK -// - sk dynamo.SK -// - v interface{} -func (_e *mockShareCodeStoreDynamoClient_Expecter) One(ctx interface{}, pk interface{}, sk interface{}, v interface{}) *mockShareCodeStoreDynamoClient_One_Call { - return &mockShareCodeStoreDynamoClient_One_Call{Call: _e.mock.On("One", ctx, pk, sk, v)} -} - -func (_c *mockShareCodeStoreDynamoClient_One_Call) Run(run func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{})) *mockShareCodeStoreDynamoClient_One_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dynamo.PK), args[2].(dynamo.SK), args[3].(interface{})) - }) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_One_Call) Return(_a0 error) *mockShareCodeStoreDynamoClient_One_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_One_Call) RunAndReturn(run func(context.Context, dynamo.PK, dynamo.SK, interface{}) error) *mockShareCodeStoreDynamoClient_One_Call { - _c.Call.Return(run) - return _c -} - -// OneByPK provides a mock function with given fields: ctx, pk, v -func (_m *mockShareCodeStoreDynamoClient) OneByPK(ctx context.Context, pk dynamo.PK, v interface{}) error { - ret := _m.Called(ctx, pk, v) - - if len(ret) == 0 { - panic("no return value specified for OneByPK") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, dynamo.PK, interface{}) error); ok { - r0 = rf(ctx, pk, v) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockShareCodeStoreDynamoClient_OneByPK_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OneByPK' -type mockShareCodeStoreDynamoClient_OneByPK_Call struct { - *mock.Call -} - -// OneByPK is a helper method to define mock.On call -// - ctx context.Context -// - pk dynamo.PK -// - v interface{} -func (_e *mockShareCodeStoreDynamoClient_Expecter) OneByPK(ctx interface{}, pk interface{}, v interface{}) *mockShareCodeStoreDynamoClient_OneByPK_Call { - return &mockShareCodeStoreDynamoClient_OneByPK_Call{Call: _e.mock.On("OneByPK", ctx, pk, v)} -} - -func (_c *mockShareCodeStoreDynamoClient_OneByPK_Call) Run(run func(ctx context.Context, pk dynamo.PK, v interface{})) *mockShareCodeStoreDynamoClient_OneByPK_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dynamo.PK), args[2].(interface{})) - }) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_OneByPK_Call) Return(_a0 error) *mockShareCodeStoreDynamoClient_OneByPK_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_OneByPK_Call) RunAndReturn(run func(context.Context, dynamo.PK, interface{}) error) *mockShareCodeStoreDynamoClient_OneByPK_Call { - _c.Call.Return(run) - return _c -} - -// OneBySK provides a mock function with given fields: ctx, sk, v -func (_m *mockShareCodeStoreDynamoClient) OneBySK(ctx context.Context, sk dynamo.SK, v interface{}) error { - ret := _m.Called(ctx, sk, v) - - if len(ret) == 0 { - panic("no return value specified for OneBySK") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, dynamo.SK, interface{}) error); ok { - r0 = rf(ctx, sk, v) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockShareCodeStoreDynamoClient_OneBySK_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OneBySK' -type mockShareCodeStoreDynamoClient_OneBySK_Call struct { - *mock.Call -} - -// OneBySK is a helper method to define mock.On call -// - ctx context.Context -// - sk dynamo.SK -// - v interface{} -func (_e *mockShareCodeStoreDynamoClient_Expecter) OneBySK(ctx interface{}, sk interface{}, v interface{}) *mockShareCodeStoreDynamoClient_OneBySK_Call { - return &mockShareCodeStoreDynamoClient_OneBySK_Call{Call: _e.mock.On("OneBySK", ctx, sk, v)} -} - -func (_c *mockShareCodeStoreDynamoClient_OneBySK_Call) Run(run func(ctx context.Context, sk dynamo.SK, v interface{})) *mockShareCodeStoreDynamoClient_OneBySK_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dynamo.SK), args[2].(interface{})) - }) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_OneBySK_Call) Return(_a0 error) *mockShareCodeStoreDynamoClient_OneBySK_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_OneBySK_Call) RunAndReturn(run func(context.Context, dynamo.SK, interface{}) error) *mockShareCodeStoreDynamoClient_OneBySK_Call { - _c.Call.Return(run) - return _c -} - -// Put provides a mock function with given fields: ctx, v -func (_m *mockShareCodeStoreDynamoClient) Put(ctx context.Context, v interface{}) error { - ret := _m.Called(ctx, v) - - if len(ret) == 0 { - panic("no return value specified for Put") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, interface{}) error); ok { - r0 = rf(ctx, v) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockShareCodeStoreDynamoClient_Put_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Put' -type mockShareCodeStoreDynamoClient_Put_Call struct { - *mock.Call -} - -// Put is a helper method to define mock.On call -// - ctx context.Context -// - v interface{} -func (_e *mockShareCodeStoreDynamoClient_Expecter) Put(ctx interface{}, v interface{}) *mockShareCodeStoreDynamoClient_Put_Call { - return &mockShareCodeStoreDynamoClient_Put_Call{Call: _e.mock.On("Put", ctx, v)} -} - -func (_c *mockShareCodeStoreDynamoClient_Put_Call) Run(run func(ctx context.Context, v interface{})) *mockShareCodeStoreDynamoClient_Put_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(interface{})) - }) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_Put_Call) Return(_a0 error) *mockShareCodeStoreDynamoClient_Put_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockShareCodeStoreDynamoClient_Put_Call) RunAndReturn(run func(context.Context, interface{}) error) *mockShareCodeStoreDynamoClient_Put_Call { - _c.Call.Return(run) - return _c -} - -// newMockShareCodeStoreDynamoClient creates a new instance of mockShareCodeStoreDynamoClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockShareCodeStoreDynamoClient(t interface { - mock.TestingT - Cleanup(func()) -}) *mockShareCodeStoreDynamoClient { - mock := &mockShareCodeStoreDynamoClient{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/app/mock_UidClient_test.go b/internal/app/mock_UidClient_test.go deleted file mode 100644 index 9678d76f07..0000000000 --- a/internal/app/mock_UidClient_test.go +++ /dev/null @@ -1,94 +0,0 @@ -// Code generated by mockery v2.42.2. DO NOT EDIT. - -package app - -import ( - context "context" - - uid "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" - mock "github.com/stretchr/testify/mock" -) - -// mockUidClient is an autogenerated mock type for the UidClient type -type mockUidClient struct { - mock.Mock -} - -type mockUidClient_Expecter struct { - mock *mock.Mock -} - -func (_m *mockUidClient) EXPECT() *mockUidClient_Expecter { - return &mockUidClient_Expecter{mock: &_m.Mock} -} - -// CreateCase provides a mock function with given fields: _a0, _a1 -func (_m *mockUidClient) CreateCase(_a0 context.Context, _a1 *uid.CreateCaseRequestBody) (uid.CreateCaseResponse, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for CreateCase") - } - - var r0 uid.CreateCaseResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *uid.CreateCaseRequestBody) (uid.CreateCaseResponse, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *uid.CreateCaseRequestBody) uid.CreateCaseResponse); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Get(0).(uid.CreateCaseResponse) - } - - if rf, ok := ret.Get(1).(func(context.Context, *uid.CreateCaseRequestBody) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockUidClient_CreateCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateCase' -type mockUidClient_CreateCase_Call struct { - *mock.Call -} - -// CreateCase is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *uid.CreateCaseRequestBody -func (_e *mockUidClient_Expecter) CreateCase(_a0 interface{}, _a1 interface{}) *mockUidClient_CreateCase_Call { - return &mockUidClient_CreateCase_Call{Call: _e.mock.On("CreateCase", _a0, _a1)} -} - -func (_c *mockUidClient_CreateCase_Call) Run(run func(_a0 context.Context, _a1 *uid.CreateCaseRequestBody)) *mockUidClient_CreateCase_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*uid.CreateCaseRequestBody)) - }) - return _c -} - -func (_c *mockUidClient_CreateCase_Call) Return(_a0 uid.CreateCaseResponse, _a1 error) *mockUidClient_CreateCase_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockUidClient_CreateCase_Call) RunAndReturn(run func(context.Context, *uid.CreateCaseRequestBody) (uid.CreateCaseResponse, error)) *mockUidClient_CreateCase_Call { - _c.Call.Return(run) - return _c -} - -// newMockUidClient creates a new instance of mockUidClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockUidClient(t interface { - mock.TestingT - Cleanup(func()) -}) *mockUidClient { - mock := &mockUidClient{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/appcontext/data.go b/internal/appcontext/data.go index d7aca7e41a..a5b4ce57a6 100644 --- a/internal/appcontext/data.go +++ b/internal/appcontext/data.go @@ -13,6 +13,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" ) type Localizer interface { @@ -52,7 +53,7 @@ type SupporterData struct { DonorFullName string OrganisationName string IsManageOrganisation bool - Permission actor.Permission + Permission supporterdata.Permission LoggedInSupporterID string } diff --git a/internal/appcontext/data_test.go b/internal/appcontext/data_test.go index 0f89586156..ea3b4823cc 100644 --- a/internal/appcontext/data_test.go +++ b/internal/appcontext/data_test.go @@ -10,6 +10,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/stretchr/testify/assert" ) @@ -91,7 +92,7 @@ func TestIsTrustCorporation(t *testing.T) { } func TestAppDataIsAdmin(t *testing.T) { - assert.True(t, Data{SupporterData: &SupporterData{Permission: actor.PermissionAdmin}}.IsAdmin()) + assert.True(t, Data{SupporterData: &SupporterData{Permission: supporterdata.PermissionAdmin}}.IsAdmin()) assert.False(t, Data{}.IsAdmin()) } diff --git a/internal/attorney/attorneypage/mock_CertificateProviderStore_test.go b/internal/attorney/attorneypage/mock_CertificateProviderStore_test.go deleted file mode 100644 index 6921b2dc74..0000000000 --- a/internal/attorney/attorneypage/mock_CertificateProviderStore_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by mockery v2.42.2. DO NOT EDIT. - -package attorneypage - -import ( - context "context" - - "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - - mock "github.com/stretchr/testify/mock" -) - -// mockCertificateProviderStore is an autogenerated mock type for the CertificateProviderStore type -type mockCertificateProviderStore struct { - mock.Mock -} - -type mockCertificateProviderStore_Expecter struct { - mock *mock.Mock -} - -func (_m *mockCertificateProviderStore) EXPECT() *mockCertificateProviderStore_Expecter { - return &mockCertificateProviderStore_Expecter{mock: &_m.Mock} -} - -// GetAny provides a mock function with given fields: ctx -func (_m *mockCertificateProviderStore) GetAny(ctx context.Context) (*certificateproviderdata.Provided, error) { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for GetAny") - } - - var r0 *certificateproviderdata.Provided - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*certificateproviderdata.Provided, error)); ok { - return rf(ctx) - } - if rf, ok := ret.Get(0).(func(context.Context) *certificateproviderdata.Provided); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*certificateproviderdata.Provided) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockCertificateProviderStore_GetAny_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAny' -type mockCertificateProviderStore_GetAny_Call struct { - *mock.Call -} - -// GetAny is a helper method to define mock.On call -// - ctx context.Context -func (_e *mockCertificateProviderStore_Expecter) GetAny(ctx interface{}) *mockCertificateProviderStore_GetAny_Call { - return &mockCertificateProviderStore_GetAny_Call{Call: _e.mock.On("GetAny", ctx)} -} - -func (_c *mockCertificateProviderStore_GetAny_Call) Run(run func(ctx context.Context)) *mockCertificateProviderStore_GetAny_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *mockCertificateProviderStore_GetAny_Call) Return(_a0 *certificateproviderdata.Provided, _a1 error) *mockCertificateProviderStore_GetAny_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockCertificateProviderStore_GetAny_Call) RunAndReturn(run func(context.Context) (*certificateproviderdata.Provided, error)) *mockCertificateProviderStore_GetAny_Call { - _c.Call.Return(run) - return _c -} - -// newMockCertificateProviderStore creates a new instance of mockCertificateProviderStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockCertificateProviderStore(t interface { - mock.TestingT - Cleanup(func()) -}) *mockCertificateProviderStore { - mock := &mockCertificateProviderStore{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/attorney/attorneypage/mock_DonorStore_test.go b/internal/attorney/attorneypage/mock_DonorStore_test.go deleted file mode 100644 index 4f851ea54a..0000000000 --- a/internal/attorney/attorneypage/mock_DonorStore_test.go +++ /dev/null @@ -1,95 +0,0 @@ -// Code generated by mockery v2.42.0. DO NOT EDIT. - -package attorneypage - -import ( - context "context" - - "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - mock "github.com/stretchr/testify/mock" -) - -// mockDonorStore is an autogenerated mock type for the DonorStore type -type mockDonorStore struct { - mock.Mock -} - -type mockDonorStore_Expecter struct { - mock *mock.Mock -} - -func (_m *mockDonorStore) EXPECT() *mockDonorStore_Expecter { - return &mockDonorStore_Expecter{mock: &_m.Mock} -} - -// GetAny provides a mock function with given fields: _a0 -func (_m *mockDonorStore) GetAny(_a0 context.Context) (*donordata.Provided, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for GetAny") - } - - var r0 *donordata.Provided - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.Provided) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockDonorStore_GetAny_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAny' -type mockDonorStore_GetAny_Call struct { - *mock.Call -} - -// GetAny is a helper method to define mock.On call -// - _a0 context.Context -func (_e *mockDonorStore_Expecter) GetAny(_a0 interface{}) *mockDonorStore_GetAny_Call { - return &mockDonorStore_GetAny_Call{Call: _e.mock.On("GetAny", _a0)} -} - -func (_c *mockDonorStore_GetAny_Call) Run(run func(_a0 context.Context)) *mockDonorStore_GetAny_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *mockDonorStore_GetAny_Call) Return(_a0 *donordata.Provided, _a1 error) *mockDonorStore_GetAny_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockDonorStore_GetAny_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockDonorStore_GetAny_Call { - _c.Call.Return(run) - return _c -} - -// newMockDonorStore creates a new instance of mockDonorStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockDonorStore(t interface { - mock.TestingT - Cleanup(func()) -}) *mockDonorStore { - mock := &mockDonorStore{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/actor/enum_novoucherdecision.go b/internal/donor/donordata/enum_novoucherdecision.go similarity index 99% rename from internal/actor/enum_novoucherdecision.go rename to internal/donor/donordata/enum_novoucherdecision.go index ac539c53c5..9ada63f08b 100644 --- a/internal/actor/enum_novoucherdecision.go +++ b/internal/donor/donordata/enum_novoucherdecision.go @@ -1,6 +1,6 @@ // Code generated by "enumerator -type NoVoucherDecision -linecomment -empty"; DO NOT EDIT. -package actor +package donordata import ( "fmt" diff --git a/internal/donor/donordata/mock_Localizer_test.go b/internal/donor/donordata/mock_Localizer_test.go deleted file mode 100644 index e17a79522d..0000000000 --- a/internal/donor/donordata/mock_Localizer_test.go +++ /dev/null @@ -1,172 +0,0 @@ -// Code generated by mockery v2.42.0. DO NOT EDIT. - -package donordata - -import mock "github.com/stretchr/testify/mock" - -// mockLocalizer is an autogenerated mock type for the Localizer type -type mockLocalizer struct { - mock.Mock -} - -type mockLocalizer_Expecter struct { - mock *mock.Mock -} - -func (_m *mockLocalizer) EXPECT() *mockLocalizer_Expecter { - return &mockLocalizer_Expecter{mock: &_m.Mock} -} - -// Count provides a mock function with given fields: messageID, count -func (_m *mockLocalizer) Count(messageID string, count int) string { - ret := _m.Called(messageID, count) - - if len(ret) == 0 { - panic("no return value specified for Count") - } - - var r0 string - if rf, ok := ret.Get(0).(func(string, int) string); ok { - r0 = rf(messageID, count) - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// mockLocalizer_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' -type mockLocalizer_Count_Call struct { - *mock.Call -} - -// Count is a helper method to define mock.On call -// - messageID string -// - count int -func (_e *mockLocalizer_Expecter) Count(messageID interface{}, count interface{}) *mockLocalizer_Count_Call { - return &mockLocalizer_Count_Call{Call: _e.mock.On("Count", messageID, count)} -} - -func (_c *mockLocalizer_Count_Call) Run(run func(messageID string, count int)) *mockLocalizer_Count_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(int)) - }) - return _c -} - -func (_c *mockLocalizer_Count_Call) Return(_a0 string) *mockLocalizer_Count_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockLocalizer_Count_Call) RunAndReturn(run func(string, int) string) *mockLocalizer_Count_Call { - _c.Call.Return(run) - return _c -} - -// Format provides a mock function with given fields: messageID, data -func (_m *mockLocalizer) Format(messageID string, data map[string]interface{}) string { - ret := _m.Called(messageID, data) - - if len(ret) == 0 { - panic("no return value specified for Format") - } - - var r0 string - if rf, ok := ret.Get(0).(func(string, map[string]interface{}) string); ok { - r0 = rf(messageID, data) - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// mockLocalizer_Format_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Format' -type mockLocalizer_Format_Call struct { - *mock.Call -} - -// Format is a helper method to define mock.On call -// - messageID string -// - data map[string]interface{} -func (_e *mockLocalizer_Expecter) Format(messageID interface{}, data interface{}) *mockLocalizer_Format_Call { - return &mockLocalizer_Format_Call{Call: _e.mock.On("Format", messageID, data)} -} - -func (_c *mockLocalizer_Format_Call) Run(run func(messageID string, data map[string]interface{})) *mockLocalizer_Format_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(map[string]interface{})) - }) - return _c -} - -func (_c *mockLocalizer_Format_Call) Return(_a0 string) *mockLocalizer_Format_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockLocalizer_Format_Call) RunAndReturn(run func(string, map[string]interface{}) string) *mockLocalizer_Format_Call { - _c.Call.Return(run) - return _c -} - -// T provides a mock function with given fields: messageID -func (_m *mockLocalizer) T(messageID string) string { - ret := _m.Called(messageID) - - if len(ret) == 0 { - panic("no return value specified for T") - } - - var r0 string - if rf, ok := ret.Get(0).(func(string) string); ok { - r0 = rf(messageID) - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// mockLocalizer_T_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'T' -type mockLocalizer_T_Call struct { - *mock.Call -} - -// T is a helper method to define mock.On call -// - messageID string -func (_e *mockLocalizer_Expecter) T(messageID interface{}) *mockLocalizer_T_Call { - return &mockLocalizer_T_Call{Call: _e.mock.On("T", messageID)} -} - -func (_c *mockLocalizer_T_Call) Run(run func(messageID string)) *mockLocalizer_T_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *mockLocalizer_T_Call) Return(_a0 string) *mockLocalizer_T_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockLocalizer_T_Call) RunAndReturn(run func(string) string) *mockLocalizer_T_Call { - _c.Call.Return(run) - return _c -} - -// newMockLocalizer creates a new instance of mockLocalizer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockLocalizer(t interface { - mock.TestingT - Cleanup(func()) -}) *mockLocalizer { - mock := &mockLocalizer{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/actor/no_voucher_decision.go b/internal/donor/donordata/no_voucher_decision.go similarity index 95% rename from internal/actor/no_voucher_decision.go rename to internal/donor/donordata/no_voucher_decision.go index 85db2f636c..fbf9668b64 100644 --- a/internal/actor/no_voucher_decision.go +++ b/internal/donor/donordata/no_voucher_decision.go @@ -1,4 +1,4 @@ -package actor +package donordata //go:generate enumerator -type NoVoucherDecision -linecomment -empty type NoVoucherDecision uint8 diff --git a/internal/donor/donorpage/what_you_can_do_now.go b/internal/donor/donorpage/what_you_can_do_now.go index 455d740ec8..361efdb7ed 100644 --- a/internal/donor/donorpage/what_you_can_do_now.go +++ b/internal/donor/donorpage/what_you_can_do_now.go @@ -4,7 +4,6 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" @@ -24,7 +23,7 @@ func WhatYouCanDoNow(tmpl template.Template, donorStore DonorStore) Handler { data := &whatYouCanDoNowData{ App: appData, Form: &whatYouCanDoNowForm{ - Options: actor.NoVoucherDecisionValues, + Options: donordata.NoVoucherDecisionValues, }, } @@ -36,15 +35,15 @@ func WhatYouCanDoNow(tmpl template.Template, donorStore DonorStore) Handler { var next page.LpaPath switch data.Form.DoNext { - case actor.ProveOwnID: + case donordata.ProveOwnID: donor.DonorIdentityUserData = identity.UserData{} next = page.Paths.TaskList - case actor.SelectNewVoucher: + case donordata.SelectNewVoucher: donor.WantVoucher = form.Yes next = page.Paths.EnterVoucher - case actor.WithdrawLPA: + case donordata.WithdrawLPA: next = page.Paths.WithdrawThisLpa - case actor.ApplyToCOP: + case donordata.ApplyToCOP: donor.RegisteringWithCourtOfProtection = true next = page.Paths.WhatHappensNextRegisteringWithCourtOfProtection } @@ -62,18 +61,18 @@ func WhatYouCanDoNow(tmpl template.Template, donorStore DonorStore) Handler { } type whatYouCanDoNowForm struct { - DoNext actor.NoVoucherDecision + DoNext donordata.NoVoucherDecision Error error - Options actor.NoVoucherDecisionOptions + Options donordata.NoVoucherDecisionOptions } func readWhatYouCanDoNowForm(r *http.Request) *whatYouCanDoNowForm { - doNext, err := actor.ParseNoVoucherDecision(page.PostFormString(r, "do-next")) + doNext, err := donordata.ParseNoVoucherDecision(page.PostFormString(r, "do-next")) return &whatYouCanDoNowForm{ DoNext: doNext, Error: err, - Options: actor.NoVoucherDecisionValues, + Options: donordata.NoVoucherDecisionValues, } } diff --git a/internal/donor/donorpage/what_you_can_do_now_test.go b/internal/donor/donorpage/what_you_can_do_now_test.go index 1a620a70c7..c5668569b9 100644 --- a/internal/donor/donorpage/what_you_can_do_now_test.go +++ b/internal/donor/donorpage/what_you_can_do_now_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" @@ -26,7 +25,7 @@ func TestGetWhatYouCanDoNow(t *testing.T) { Execute(w, &whatYouCanDoNowData{ App: testAppData, Form: &whatYouCanDoNowForm{ - Options: actor.NoVoucherDecisionValues, + Options: donordata.NoVoucherDecisionValues, }, }). Return(nil) @@ -51,18 +50,18 @@ func TestGetWhatYouCanDoNowWhenTemplateError(t *testing.T) { } func TestPostWhatYouCanDoNow(t *testing.T) { - testcases := map[actor.NoVoucherDecision]struct { + testcases := map[donordata.NoVoucherDecision]struct { expectedPath string expectedDonor *donordata.Provided }{ - actor.ProveOwnID: { + donordata.ProveOwnID: { expectedPath: page.Paths.TaskList.Format("lpa-id"), expectedDonor: &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{}, }, }, - actor.SelectNewVoucher: { + donordata.SelectNewVoucher: { expectedPath: page.Paths.EnterVoucher.Format("lpa-id"), expectedDonor: &donordata.Provided{ LpaID: "lpa-id", @@ -70,14 +69,14 @@ func TestPostWhatYouCanDoNow(t *testing.T) { DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, }, }, - actor.WithdrawLPA: { + donordata.WithdrawLPA: { expectedPath: page.Paths.WithdrawThisLpa.Format("lpa-id"), expectedDonor: &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, }, }, - actor.ApplyToCOP: { + donordata.ApplyToCOP: { expectedPath: page.Paths.WhatHappensNextRegisteringWithCourtOfProtection.Format("lpa-id"), expectedDonor: &donordata.Provided{ LpaID: "lpa-id", @@ -114,7 +113,7 @@ func TestPostWhatYouCanDoNow(t *testing.T) { func TestPostWhatYouCanDoNowWhenDonorStoreError(t *testing.T) { f := url.Values{ - "do-next": {actor.ApplyToCOP.String()}, + "do-next": {donordata.ApplyToCOP.String()}, } w := httptest.NewRecorder() @@ -168,7 +167,7 @@ func TestReadWhatYouCanDoNowForm(t *testing.T) { result := readWhatYouCanDoNowForm(r) - assert.Equal(actor.WithdrawLPA, result.DoNext) + assert.Equal(donordata.WithdrawLPA, result.DoNext) assert.Nil(result.Error) } @@ -179,12 +178,12 @@ func TestWhatYouCanDoNowFormValidate(t *testing.T) { }{ "valid": { form: &whatYouCanDoNowForm{ - DoNext: actor.WithdrawLPA, + DoNext: donordata.WithdrawLPA, }, }, "invalid": { form: &whatYouCanDoNowForm{ - DoNext: actor.NoVoucherDecision(99), + DoNext: donordata.NoVoucherDecision(99), Error: expectedError, }, errors: validation. diff --git a/internal/dynamo/mock_Logger_test.go b/internal/dynamo/mock_Logger_test.go deleted file mode 100644 index b27d24d480..0000000000 --- a/internal/dynamo/mock_Logger_test.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by mockery v2.42.2. DO NOT EDIT. - -package dynamo - -import mock "github.com/stretchr/testify/mock" - -// mockLogger is an autogenerated mock type for the Logger type -type mockLogger struct { - mock.Mock -} - -type mockLogger_Expecter struct { - mock *mock.Mock -} - -func (_m *mockLogger) EXPECT() *mockLogger_Expecter { - return &mockLogger_Expecter{mock: &_m.Mock} -} - -// Print provides a mock function with given fields: v -func (_m *mockLogger) Print(v ...interface{}) { - var _ca []interface{} - _ca = append(_ca, v...) - _m.Called(_ca...) -} - -// mockLogger_Print_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Print' -type mockLogger_Print_Call struct { - *mock.Call -} - -// Print is a helper method to define mock.On call -// - v ...interface{} -func (_e *mockLogger_Expecter) Print(v ...interface{}) *mockLogger_Print_Call { - return &mockLogger_Print_Call{Call: _e.mock.On("Print", - append([]interface{}{}, v...)...)} -} - -func (_c *mockLogger_Print_Call) Run(run func(v ...interface{})) *mockLogger_Print_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]interface{}, len(args)-0) - for i, a := range args[0:] { - if a != nil { - variadicArgs[i] = a.(interface{}) - } - } - run(variadicArgs...) - }) - return _c -} - -func (_c *mockLogger_Print_Call) Return() *mockLogger_Print_Call { - _c.Call.Return() - return _c -} - -func (_c *mockLogger_Print_Call) RunAndReturn(run func(...interface{})) *mockLogger_Print_Call { - _c.Call.Return(run) - return _c -} - -// newMockLogger creates a new instance of mockLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockLogger(t interface { - mock.TestingT - Cleanup(func()) -}) *mockLogger { - mock := &mockLogger{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/page/fixtures/supporter.go b/internal/page/fixtures/supporter.go index 70572daa98..6f5a13d31a 100644 --- a/internal/page/fixtures/supporter.go +++ b/internal/page/fixtures/supporter.go @@ -22,19 +22,20 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) type OrganisationStore interface { - Create(context.Context, *actor.Member, string) (*actor.Organisation, error) + Create(context.Context, *supporterdata.Member, string) (*supporterdata.Organisation, error) CreateLPA(context.Context) (*donordata.Provided, error) } type MemberStore interface { - Create(ctx context.Context, firstNames, lastName string) (*actor.Member, error) - CreateFromInvite(ctx context.Context, invite *actor.MemberInvite) error - CreateMemberInvite(ctx context.Context, organisation *actor.Organisation, firstNames, lastname, email, code string, permission actor.Permission) error - Put(ctx context.Context, member *actor.Member) error + Create(ctx context.Context, firstNames, lastName string) (*supporterdata.Member, error) + CreateFromInvite(ctx context.Context, invite *supporterdata.MemberInvite) error + CreateMemberInvite(ctx context.Context, organisation *supporterdata.Organisation, firstNames, lastname, email, code string, permission supporterdata.Permission) error + Put(ctx context.Context, member *supporterdata.Member) error } type ShareCodeStore interface { @@ -97,7 +98,7 @@ func Supporter( organisationCtx := appcontext.ContextWithSession(r.Context(), &appcontext.Session{OrganisationID: org.ID}) if suspended { - member.Status = actor.StatusSuspended + member.Status = supporterdata.StatusSuspended if err := memberStore.Put(organisationCtx, member); err != nil { return err @@ -222,7 +223,7 @@ func Supporter( now = now.Add(time.Hour * -time.Duration(48)) } - invite := &actor.MemberInvite{ + invite := &supporterdata.MemberInvite{ PK: dynamo.OrganisationKey(org.ID), SK: dynamo.MemberInviteKey(email), CreatedAt: now, @@ -231,7 +232,7 @@ func Supporter( Email: email, FirstNames: member.Firstnames, LastName: member.Lastname, - Permission: actor.PermissionAdmin, + Permission: supporterdata.PermissionAdmin, ReferenceNumber: random.String(12), } @@ -249,9 +250,9 @@ func Supporter( memberEmailSub := make(map[string]string) - permission, err := actor.ParsePermission(permission) + permission, err := supporterdata.ParsePermission(permission) if err != nil { - permission = actor.PermissionNone + permission = supporterdata.PermissionNone } for i, member := range orgMemberNames { @@ -265,7 +266,7 @@ func Supporter( if err = memberStore.CreateFromInvite( memberCtx, - &actor.MemberInvite{ + &supporterdata.MemberInvite{ PK: dynamo.OrganisationKey(random.String(12)), SK: dynamo.MemberInviteKey(random.String(12)), CreatedAt: time.Now(), diff --git a/internal/page/mock_AttorneyStore_test.go b/internal/page/mock_AttorneyStore_test.go deleted file mode 100644 index 2247c96973..0000000000 --- a/internal/page/mock_AttorneyStore_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. - -package page - -import ( - context "context" - - "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - - mock "github.com/stretchr/testify/mock" -) - -// mockAttorneyStore is an autogenerated mock type for the AttorneyStore type -type mockAttorneyStore struct { - mock.Mock -} - -// Create provides a mock function with given fields: _a0, _a1, _a2, _a3, _a4 -func (_m *mockAttorneyStore) Create(_a0 context.Context, _a1 string, _a2 string, _a3 bool, _a4 bool) (*attorneydata.Provided, error) { - ret := _m.Called(_a0, _a1, _a2, _a3, _a4) - - var r0 *attorneydata.Provided - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, bool, bool) (*attorneydata.Provided, error)); ok { - return rf(_a0, _a1, _a2, _a3, _a4) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, bool, bool) *attorneydata.Provided); ok { - r0 = rf(_a0, _a1, _a2, _a3, _a4) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*attorneydata.Provided) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, bool, bool) error); ok { - r1 = rf(_a0, _a1, _a2, _a3, _a4) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Put provides a mock function with given fields: _a0, _a1 -func (_m *mockAttorneyStore) Put(_a0 context.Context, _a1 *attorneydata.Provided) error { - ret := _m.Called(_a0, _a1) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *attorneydata.Provided) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTnewMockAttorneyStore interface { - mock.TestingT - Cleanup(func()) -} - -// newMockAttorneyStore creates a new instance of mockAttorneyStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func newMockAttorneyStore(t mockConstructorTestingTnewMockAttorneyStore) *mockAttorneyStore { - mock := &mockAttorneyStore{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/page/mock_DataStore_test.go b/internal/page/mock_DataStore_test.go deleted file mode 100644 index f08d29373d..0000000000 --- a/internal/page/mock_DataStore_test.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. - -package page - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" -) - -// mockDataStore is an autogenerated mock type for the DataStore type -type mockDataStore struct { - mock.Mock -} - -// Get provides a mock function with given fields: ctx, pk, sk, v -func (_m *mockDataStore) Get(ctx context.Context, pk string, sk string, v interface{}) error { - ret := _m.Called(ctx, pk, sk, v) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, interface{}) error); ok { - r0 = rf(ctx, pk, sk, v) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// GetAllByGsi provides a mock function with given fields: ctx, gsi, sk, v -func (_m *mockDataStore) GetAllByGsi(ctx context.Context, gsi string, sk string, v interface{}) error { - ret := _m.Called(ctx, gsi, sk, v) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, interface{}) error); ok { - r0 = rf(ctx, gsi, sk, v) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// GetOneByPartialSK provides a mock function with given fields: ctx, pk, partialSk, v -func (_m *mockDataStore) GetOneByPartialSK(ctx context.Context, pk string, partialSk string, v interface{}) error { - ret := _m.Called(ctx, pk, partialSk, v) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, interface{}) error); ok { - r0 = rf(ctx, pk, partialSk, v) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Put provides a mock function with given fields: _a0, _a1, _a2, _a3 -func (_m *mockDataStore) Put(_a0 context.Context, _a1 string, _a2 string, _a3 interface{}) error { - ret := _m.Called(_a0, _a1, _a2, _a3) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, interface{}) error); ok { - r0 = rf(_a0, _a1, _a2, _a3) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTnewMockDataStore interface { - mock.TestingT - Cleanup(func()) -} - -// newMockDataStore creates a new instance of mockDataStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func newMockDataStore(t mockConstructorTestingTnewMockDataStore) *mockDataStore { - mock := &mockDataStore{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/page/mock_shareCodeEmail_test.go b/internal/page/mock_shareCodeEmail_test.go deleted file mode 100644 index 1b2fad7233..0000000000 --- a/internal/page/mock_shareCodeEmail_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// Code generated by mockery v2.42.0. DO NOT EDIT. - -package page - -import ( - notify "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" - mock "github.com/stretchr/testify/mock" -) - -// mockShareCodeEmail is an autogenerated mock type for the shareCodeEmail type -type mockShareCodeEmail struct { - mock.Mock -} - -type mockShareCodeEmail_Expecter struct { - mock *mock.Mock -} - -func (_m *mockShareCodeEmail) EXPECT() *mockShareCodeEmail_Expecter { - return &mockShareCodeEmail_Expecter{mock: &_m.Mock} -} - -// WithShareCode provides a mock function with given fields: _a0 -func (_m *mockShareCodeEmail) WithShareCode(_a0 string) notify.Email { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for WithShareCode") - } - - var r0 notify.Email - if rf, ok := ret.Get(0).(func(string) notify.Email); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(notify.Email) - } - } - - return r0 -} - -// mockShareCodeEmail_WithShareCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithShareCode' -type mockShareCodeEmail_WithShareCode_Call struct { - *mock.Call -} - -// WithShareCode is a helper method to define mock.On call -// - _a0 string -func (_e *mockShareCodeEmail_Expecter) WithShareCode(_a0 interface{}) *mockShareCodeEmail_WithShareCode_Call { - return &mockShareCodeEmail_WithShareCode_Call{Call: _e.mock.On("WithShareCode", _a0)} -} - -func (_c *mockShareCodeEmail_WithShareCode_Call) Run(run func(_a0 string)) *mockShareCodeEmail_WithShareCode_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *mockShareCodeEmail_WithShareCode_Call) Return(_a0 notify.Email) *mockShareCodeEmail_WithShareCode_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockShareCodeEmail_WithShareCode_Call) RunAndReturn(run func(string) notify.Email) *mockShareCodeEmail_WithShareCode_Call { - _c.Call.Return(run) - return _c -} - -// newMockShareCodeEmail creates a new instance of mockShareCodeEmail. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockShareCodeEmail(t interface { - mock.TestingT - Cleanup(func()) -}) *mockShareCodeEmail { - mock := &mockShareCodeEmail{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/page/supporter/mock_LpaStoreClient_test.go b/internal/page/supporter/mock_LpaStoreClient_test.go deleted file mode 100644 index 8eceb8a7d4..0000000000 --- a/internal/page/supporter/mock_LpaStoreClient_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by mockery v2.42.0. DO NOT EDIT. - -package supporter - -import ( - context "context" - - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" - mock "github.com/stretchr/testify/mock" -) - -// mockLpaStoreClient is an autogenerated mock type for the LpaStoreClient type -type mockLpaStoreClient struct { - mock.Mock -} - -type mockLpaStoreClient_Expecter struct { - mock *mock.Mock -} - -func (_m *mockLpaStoreClient) EXPECT() *mockLpaStoreClient_Expecter { - return &mockLpaStoreClient_Expecter{mock: &_m.Mock} -} - -// Lpa provides a mock function with given fields: ctx, uid -func (_m *mockLpaStoreClient) Lpa(ctx context.Context, uid string) (*lpastore.Lpa, error) { - ret := _m.Called(ctx, uid) - - if len(ret) == 0 { - panic("no return value specified for Lpa") - } - - var r0 *lpastore.Lpa - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*lpastore.Lpa, error)); ok { - return rf(ctx, uid) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *lpastore.Lpa); ok { - r0 = rf(ctx, uid) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*lpastore.Lpa) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, uid) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockLpaStoreClient_Lpa_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Lpa' -type mockLpaStoreClient_Lpa_Call struct { - *mock.Call -} - -// Lpa is a helper method to define mock.On call -// - ctx context.Context -// - uid string -func (_e *mockLpaStoreClient_Expecter) Lpa(ctx interface{}, uid interface{}) *mockLpaStoreClient_Lpa_Call { - return &mockLpaStoreClient_Lpa_Call{Call: _e.mock.On("Lpa", ctx, uid)} -} - -func (_c *mockLpaStoreClient_Lpa_Call) Run(run func(ctx context.Context, uid string)) *mockLpaStoreClient_Lpa_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *mockLpaStoreClient_Lpa_Call) Return(_a0 *lpastore.Lpa, _a1 error) *mockLpaStoreClient_Lpa_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockLpaStoreClient_Lpa_Call) RunAndReturn(run func(context.Context, string) (*lpastore.Lpa, error)) *mockLpaStoreClient_Lpa_Call { - _c.Call.Return(run) - return _c -} - -// newMockLpaStoreClient creates a new instance of mockLpaStoreClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockLpaStoreClient(t interface { - mock.TestingT - Cleanup(func()) -}) *mockLpaStoreClient { - mock := &mockLpaStoreClient{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/app/member_store.go b/internal/supporter/member_store.go similarity index 70% rename from internal/app/member_store.go rename to internal/supporter/member_store.go index 3afbbdfdfd..925a21a28c 100644 --- a/internal/app/member_store.go +++ b/internal/supporter/member_store.go @@ -1,4 +1,4 @@ -package app +package supporter import ( "context" @@ -8,18 +8,37 @@ import ( "strings" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + "github.com/ministryofjustice/opg-modernising-lpa/internal/random" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" ) -type memberStore struct { +type DynamoClient interface { + AllByPartialSK(ctx context.Context, pk dynamo.PK, partialSK dynamo.SK, v interface{}) error + AllBySK(ctx context.Context, sk dynamo.SK, v interface{}) error + Create(ctx context.Context, v interface{}) error + DeleteOne(ctx context.Context, pk dynamo.PK, sk dynamo.SK) error + One(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error + OneBySK(ctx context.Context, sk dynamo.SK, v interface{}) error + Put(ctx context.Context, v interface{}) error +} + +type MemberStore struct { dynamoClient DynamoClient uuidString func() string now func() time.Time } -func (s *memberStore) CreateMemberInvite(ctx context.Context, organisation *actor.Organisation, firstNames, lastname, email, referenceNumber string, permission actor.Permission) error { +func NewMemberStore(dynamoClient DynamoClient) *MemberStore { + return &MemberStore{ + dynamoClient: dynamoClient, + uuidString: random.UuidString, + now: time.Now, + } +} + +func (s *MemberStore) CreateMemberInvite(ctx context.Context, organisation *supporterdata.Organisation, firstNames, lastname, email, referenceNumber string, permission supporterdata.Permission) error { data, err := appcontext.SessionFromContext(ctx) if err != nil { return err @@ -29,7 +48,7 @@ func (s *memberStore) CreateMemberInvite(ctx context.Context, organisation *acto return errors.New("memberStore.Get requires OrganisationID") } - invite := &actor.MemberInvite{ + invite := &supporterdata.MemberInvite{ PK: dynamo.OrganisationKey(data.OrganisationID), SK: dynamo.MemberInviteKey(email), CreatedAt: s.now(), @@ -49,7 +68,7 @@ func (s *memberStore) CreateMemberInvite(ctx context.Context, organisation *acto return nil } -func (s *memberStore) DeleteMemberInvite(ctx context.Context, organisationID, email string) error { +func (s *MemberStore) DeleteMemberInvite(ctx context.Context, organisationID, email string) error { if err := s.dynamoClient.DeleteOne(ctx, dynamo.OrganisationKey(organisationID), dynamo.MemberInviteKey(email)); err != nil { return fmt.Errorf("error deleting member invite: %w", err) } @@ -57,7 +76,7 @@ func (s *memberStore) DeleteMemberInvite(ctx context.Context, organisationID, em return nil } -func (s *memberStore) Create(ctx context.Context, firstNames, lastName string) (*actor.Member, error) { +func (s *MemberStore) Create(ctx context.Context, firstNames, lastName string) (*supporterdata.Member, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -73,7 +92,7 @@ func (s *memberStore) Create(ctx context.Context, firstNames, lastName string) ( organisationID := s.uuidString() - member := &actor.Member{ + member := &supporterdata.Member{ PK: dynamo.OrganisationKey(organisationID), SK: dynamo.MemberKey(data.SessionID), ID: s.uuidString(), @@ -83,8 +102,8 @@ func (s *memberStore) Create(ctx context.Context, firstNames, lastName string) ( LastName: lastName, CreatedAt: s.now(), UpdatedAt: s.now(), - Permission: actor.PermissionAdmin, - Status: actor.StatusActive, + Permission: supporterdata.PermissionAdmin, + Status: supporterdata.StatusActive, LastLoggedInAt: s.now(), } @@ -105,7 +124,7 @@ func (s *memberStore) Create(ctx context.Context, firstNames, lastName string) ( return member, nil } -func (s *memberStore) CreateFromInvite(ctx context.Context, invite *actor.MemberInvite) error { +func (s *MemberStore) CreateFromInvite(ctx context.Context, invite *supporterdata.MemberInvite) error { data, err := appcontext.SessionFromContext(ctx) if err != nil { return err @@ -115,7 +134,7 @@ func (s *memberStore) CreateFromInvite(ctx context.Context, invite *actor.Member return errors.New("memberStore.CreateFromInvite requires SessionID") } - member := &actor.Member{ + member := &supporterdata.Member{ PK: dynamo.OrganisationKey(invite.OrganisationID), SK: dynamo.MemberKey(data.SessionID), CreatedAt: s.now(), @@ -150,7 +169,7 @@ func (s *memberStore) CreateFromInvite(ctx context.Context, invite *actor.Member return nil } -func (s *memberStore) InvitedMember(ctx context.Context) (*actor.MemberInvite, error) { +func (s *MemberStore) InvitedMember(ctx context.Context) (*supporterdata.MemberInvite, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -160,7 +179,7 @@ func (s *memberStore) InvitedMember(ctx context.Context) (*actor.MemberInvite, e return nil, errors.New("memberStore.InvitedMember requires Email") } - var invitedMember *actor.MemberInvite + var invitedMember *supporterdata.MemberInvite if err := s.dynamoClient.OneBySK(ctx, dynamo.MemberInviteKey(data.Email), &invitedMember); err != nil { return nil, err } @@ -168,7 +187,7 @@ func (s *memberStore) InvitedMember(ctx context.Context) (*actor.MemberInvite, e return invitedMember, nil } -func (s *memberStore) InvitedMembers(ctx context.Context) ([]*actor.MemberInvite, error) { +func (s *MemberStore) InvitedMembers(ctx context.Context) ([]*supporterdata.MemberInvite, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -178,7 +197,7 @@ func (s *memberStore) InvitedMembers(ctx context.Context) ([]*actor.MemberInvite return nil, errors.New("memberStore.InvitedMembers requires OrganisationID") } - var invitedMembers []*actor.MemberInvite + var invitedMembers []*supporterdata.MemberInvite if err := s.dynamoClient.AllByPartialSK(ctx, dynamo.OrganisationKey(data.OrganisationID), dynamo.MemberInviteKey(""), &invitedMembers); err != nil { return nil, err } @@ -186,7 +205,7 @@ func (s *memberStore) InvitedMembers(ctx context.Context) ([]*actor.MemberInvite return invitedMembers, nil } -func (s *memberStore) InvitedMembersByEmail(ctx context.Context) ([]*actor.MemberInvite, error) { +func (s *MemberStore) InvitedMembersByEmail(ctx context.Context) ([]*supporterdata.MemberInvite, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -196,7 +215,7 @@ func (s *memberStore) InvitedMembersByEmail(ctx context.Context) ([]*actor.Membe return nil, errors.New("memberStore.InvitedMembersByEmail requires Email") } - var invitedMembers []*actor.MemberInvite + var invitedMembers []*supporterdata.MemberInvite if err := s.dynamoClient.AllBySK(ctx, dynamo.MemberInviteKey(data.Email), &invitedMembers); err != nil { return nil, err } @@ -204,7 +223,7 @@ func (s *memberStore) InvitedMembersByEmail(ctx context.Context) ([]*actor.Membe return invitedMembers, nil } -func (s *memberStore) GetAll(ctx context.Context) ([]*actor.Member, error) { +func (s *MemberStore) GetAll(ctx context.Context) ([]*supporterdata.Member, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -214,19 +233,19 @@ func (s *memberStore) GetAll(ctx context.Context) ([]*actor.Member, error) { return nil, errors.New("memberStore.GetAll requires OrganisationID") } - var members []*actor.Member + var members []*supporterdata.Member if err := s.dynamoClient.AllByPartialSK(ctx, dynamo.OrganisationKey(data.OrganisationID), dynamo.MemberKey(""), &members); err != nil { return nil, err } - slices.SortFunc(members, func(a, b *actor.Member) int { + slices.SortFunc(members, func(a, b *supporterdata.Member) int { return strings.Compare(a.FirstNames, b.FirstNames) }) return members, nil } -func (s *memberStore) GetByID(ctx context.Context, memberID string) (*actor.Member, error) { +func (s *MemberStore) GetByID(ctx context.Context, memberID string) (*supporterdata.Member, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -241,7 +260,7 @@ func (s *memberStore) GetByID(ctx context.Context, memberID string) (*actor.Memb return nil, err } - var member *actor.Member + var member *supporterdata.Member if err := s.dynamoClient.One(ctx, link.PK, link.MemberSK, &member); err != nil { return nil, err } @@ -249,7 +268,7 @@ func (s *memberStore) GetByID(ctx context.Context, memberID string) (*actor.Memb return member, nil } -func (s *memberStore) Get(ctx context.Context) (*actor.Member, error) { +func (s *MemberStore) Get(ctx context.Context) (*supporterdata.Member, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -263,7 +282,7 @@ func (s *memberStore) Get(ctx context.Context) (*actor.Member, error) { return nil, errors.New("memberStore.Get requires OrganisationID") } - var member *actor.Member + var member *supporterdata.Member if err := s.dynamoClient.One(ctx, dynamo.OrganisationKey(data.OrganisationID), dynamo.MemberKey(data.SessionID), &member); err != nil { return nil, err } @@ -271,7 +290,7 @@ func (s *memberStore) Get(ctx context.Context) (*actor.Member, error) { return member, nil } -func (s *memberStore) GetAny(ctx context.Context) (*actor.Member, error) { +func (s *MemberStore) GetAny(ctx context.Context) (*supporterdata.Member, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -281,7 +300,7 @@ func (s *memberStore) GetAny(ctx context.Context) (*actor.Member, error) { return nil, errors.New("memberStore.Get requires SessionID") } - var member *actor.Member + var member *supporterdata.Member if err := s.dynamoClient.OneBySK(ctx, dynamo.MemberKey(data.SessionID), &member); err != nil { return nil, err } @@ -289,7 +308,7 @@ func (s *memberStore) GetAny(ctx context.Context) (*actor.Member, error) { return member, nil } -func (s *memberStore) Put(ctx context.Context, member *actor.Member) error { +func (s *MemberStore) Put(ctx context.Context, member *supporterdata.Member) error { member.UpdatedAt = s.now() return s.dynamoClient.Put(ctx, member) } diff --git a/internal/app/member_store_test.go b/internal/supporter/member_store_test.go similarity index 80% rename from internal/app/member_store_test.go rename to internal/supporter/member_store_test.go index c76be17a1b..d98b91f6f8 100644 --- a/internal/app/member_store_test.go +++ b/internal/supporter/member_store_test.go @@ -1,12 +1,12 @@ -package app +package supporter import ( "context" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -16,7 +16,7 @@ func TestMemberStoreCreateMemberInvite(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). - Create(ctx, &actor.MemberInvite{ + Create(ctx, &supporterdata.MemberInvite{ PK: dynamo.OrganisationKey("an-id"), SK: dynamo.MemberInviteKey("email@example.com"), CreatedAt: testNow, @@ -25,14 +25,14 @@ func TestMemberStoreCreateMemberInvite(t *testing.T) { Email: "email@example.com", FirstNames: "a", LastName: "b", - Permission: actor.PermissionNone, + Permission: supporterdata.PermissionNone, ReferenceNumber: "abcde", }). Return(nil) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn} - err := memberStore.CreateMemberInvite(ctx, &actor.Organisation{ID: "a-uuid", Name: "org name"}, "a", "b", "email@example.com", "abcde", actor.PermissionNone) + err := memberStore.CreateMemberInvite(ctx, &supporterdata.Organisation{ID: "a-uuid", Name: "org name"}, "a", "b", "email@example.com", "abcde", supporterdata.PermissionNone) assert.Nil(t, err) } @@ -42,12 +42,12 @@ func TestMemberStoreCreateMemberInviteWithSessionMissing(t *testing.T) { "missing OrganisationID": appcontext.ContextWithSession(context.Background(), &appcontext.Session{}), } - memberStore := &memberStore{now: testNowFn} + memberStore := &MemberStore{now: testNowFn} for name, ctx := range testcases { t.Run(name, func(t *testing.T) { - err := memberStore.CreateMemberInvite(ctx, &actor.Organisation{}, "a", "b", "email@example.com", "abcde", actor.PermissionNone) + err := memberStore.CreateMemberInvite(ctx, &supporterdata.Organisation{}, "a", "b", "email@example.com", "abcde", supporterdata.PermissionNone) assert.Error(t, err) }) @@ -58,14 +58,14 @@ func TestMemberStoreInvitedMember(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{Email: "a@example.org"}) dynamoClient := newMockDynamoClient(t) - dynamoClient.ExpectOneBySK(ctx, dynamo.MemberInviteKey("a@example.org"), &actor.MemberInvite{OrganisationID: "an-id"}, nil) + dynamoClient.ExpectOneBySK(ctx, dynamo.MemberInviteKey("a@example.org"), &supporterdata.MemberInvite{OrganisationID: "an-id"}, nil) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} invitedMember, err := memberStore.InvitedMember(ctx) assert.Nil(t, err) - assert.Equal(t, &actor.MemberInvite{OrganisationID: "an-id"}, invitedMember) + assert.Equal(t, &supporterdata.MemberInvite{OrganisationID: "an-id"}, invitedMember) } func TestMemberStoreInvitedMemberWhenDynamoError(t *testing.T) { @@ -74,7 +74,7 @@ func TestMemberStoreInvitedMemberWhenDynamoError(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.ExpectOneBySK(ctx, mock.Anything, mock.Anything, expectedError) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.InvitedMember(ctx) @@ -89,7 +89,7 @@ func TestMemberStoreInvitedMemberWhenSessionMissing(t *testing.T) { for name, ctx := range testcases { t.Run(name, func(t *testing.T) { - memberStore := &memberStore{now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.InvitedMember(ctx) @@ -106,9 +106,9 @@ func TestMemberStoreCreateMemberInviteWhenErrors(t *testing.T) { Create(ctx, mock.Anything). Return(expectedError) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn} - err := memberStore.CreateMemberInvite(ctx, &actor.Organisation{}, "a", "b", "email@example.com", "abcde", actor.PermissionNone) + err := memberStore.CreateMemberInvite(ctx, &supporterdata.Organisation{}, "a", "b", "email@example.com", "abcde", supporterdata.PermissionNone) assert.ErrorIs(t, err, expectedError) } @@ -117,14 +117,14 @@ func TestMemberStoreInvitedMembers(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.ExpectAllByPartialSK(ctx, dynamo.OrganisationKey("an-id"), - dynamo.MemberInviteKey(""), []*actor.MemberInvite{{OrganisationID: "an-id"}, {OrganisationID: "an-id"}}, nil) + dynamo.MemberInviteKey(""), []*supporterdata.MemberInvite{{OrganisationID: "an-id"}, {OrganisationID: "an-id"}}, nil) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} invitedMembers, err := memberStore.InvitedMembers(ctx) assert.Nil(t, err) - assert.Equal(t, []*actor.MemberInvite{{OrganisationID: "an-id"}, {OrganisationID: "an-id"}}, invitedMembers) + assert.Equal(t, []*supporterdata.MemberInvite{{OrganisationID: "an-id"}, {OrganisationID: "an-id"}}, invitedMembers) } func TestMemberStoreInvitedMembersWhenSessionMissing(t *testing.T) { @@ -135,7 +135,7 @@ func TestMemberStoreInvitedMembersWhenSessionMissing(t *testing.T) { for name, ctx := range testcases { t.Run(name, func(t *testing.T) { - memberStore := &memberStore{now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.InvitedMembers(ctx) @@ -149,9 +149,9 @@ func TestMemberStoreInvitedMembersWhenDynamoClientError(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.ExpectAllByPartialSK(ctx, dynamo.OrganisationKey("an-id"), - dynamo.MemberInviteKey(""), []*actor.MemberInvite{}, expectedError) + dynamo.MemberInviteKey(""), []*supporterdata.MemberInvite{}, expectedError) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.InvitedMembers(ctx) @@ -162,17 +162,17 @@ func TestMemberStoreInvitedMembersByEmail(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{Email: "a@example.org"}) dynamoClient := newMockDynamoClient(t) - dynamoClient.ExpectAllBySK(ctx, dynamo.MemberInviteKey("a@example.org"), []*actor.MemberInvite{ + dynamoClient.ExpectAllBySK(ctx, dynamo.MemberInviteKey("a@example.org"), []*supporterdata.MemberInvite{ {OrganisationID: "an-id", Email: "a@example.org"}, {OrganisationID: "another-id", Email: "a@example.org"}, }, nil) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} invitedMembers, err := memberStore.InvitedMembersByEmail(ctx) assert.Nil(t, err) - assert.Equal(t, []*actor.MemberInvite{ + assert.Equal(t, []*supporterdata.MemberInvite{ {OrganisationID: "an-id", Email: "a@example.org"}, {OrganisationID: "another-id", Email: "a@example.org"}, }, invitedMembers) @@ -184,7 +184,7 @@ func TestMemberStoreInvitedMembersByEmailWhenDynamoError(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.ExpectAllBySK(ctx, mock.Anything, mock.Anything, expectedError) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.InvitedMembersByEmail(ctx) @@ -199,7 +199,7 @@ func TestMemberStoreInvitedMembersByEmailWhenSessionMissing(t *testing.T) { for name, ctx := range testcases { t.Run(name, func(t *testing.T) { - memberStore := &memberStore{now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.InvitedMembersByEmail(ctx) @@ -213,15 +213,15 @@ func TestPut(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). - Put(ctx, &actor.Member{PK: dynamo.OrganisationKey("123"), SK: dynamo.MemberKey("456"), UpdatedAt: testNow}). + Put(ctx, &supporterdata.Member{PK: dynamo.OrganisationKey("123"), SK: dynamo.MemberKey("456"), UpdatedAt: testNow}). Return(nil) - store := &memberStore{ + store := &MemberStore{ dynamoClient: dynamoClient, now: testNowFn, } - err := store.Put(ctx, &actor.Member{PK: dynamo.OrganisationKey("123"), SK: dynamo.MemberKey("456")}) + err := store.Put(ctx, &supporterdata.Member{PK: dynamo.OrganisationKey("123"), SK: dynamo.MemberKey("456")}) assert.Nil(t, err) } @@ -233,12 +233,12 @@ func TestPutWhenDynamoError(t *testing.T) { Put(mock.Anything, mock.Anything). Return(expectedError) - store := &memberStore{ + store := &MemberStore{ dynamoClient: dynamoClient, now: testNowFn, } - err := store.Put(ctx, &actor.Member{PK: dynamo.OrganisationKey("123"), SK: dynamo.MemberKey("456")}) + err := store.Put(ctx, &supporterdata.Member{PK: dynamo.OrganisationKey("123"), SK: dynamo.MemberKey("456")}) assert.Equal(t, expectedError, err) } @@ -247,14 +247,14 @@ func TestMemberStoreGetAll(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.ExpectAllByPartialSK(ctx, dynamo.OrganisationKey("an-id"), - dynamo.MemberKey(""), []*actor.Member{{FirstNames: "a"}, {FirstNames: "c"}, {FirstNames: "b"}}, nil) + dynamo.MemberKey(""), []*supporterdata.Member{{FirstNames: "a"}, {FirstNames: "c"}, {FirstNames: "b"}}, nil) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} members, err := memberStore.GetAll(ctx) assert.Nil(t, err) - assert.Equal(t, []*actor.Member{{FirstNames: "a"}, {FirstNames: "b"}, {FirstNames: "c"}}, members) + assert.Equal(t, []*supporterdata.Member{{FirstNames: "a"}, {FirstNames: "b"}, {FirstNames: "c"}}, members) } func TestMemberStoreGetAllWhenSessionMissing(t *testing.T) { @@ -265,7 +265,7 @@ func TestMemberStoreGetAllWhenSessionMissing(t *testing.T) { for name, ctx := range testcases { t.Run(name, func(t *testing.T) { - memberStore := &memberStore{now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.GetAll(ctx) @@ -279,9 +279,9 @@ func TestMemberStoreGetAllWhenDynamoClientError(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.ExpectAllByPartialSK(ctx, dynamo.OrganisationKey("an-id"), - dynamo.MemberKey(""), []*actor.MemberInvite{}, expectedError) + dynamo.MemberKey(""), []*supporterdata.MemberInvite{}, expectedError) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.GetAll(ctx) @@ -293,14 +293,14 @@ func TestMemberStoreGet(t *testing.T) { OrganisationID: "a-uuid", SessionID: "session-id", }) - member := &actor.Member{FirstNames: "a"} + member := &supporterdata.Member{FirstNames: "a"} dynamoClient := newMockDynamoClient(t) dynamoClient. ExpectOne(ctx, dynamo.OrganisationKey("a-uuid"), dynamo.MemberKey("session-id"), member, nil) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} result, err := memberStore.Get(ctx) assert.Nil(t, err) @@ -316,7 +316,7 @@ func TestMemberStoreGetWithSessionMissing(t *testing.T) { for name, ctx := range testcases { t.Run(name, func(t *testing.T) { - memberStore := &memberStore{} + memberStore := &MemberStore{} _, err := memberStore.Get(ctx) assert.Error(t, err) @@ -331,7 +331,7 @@ func TestMemberStoreGetWhenErrors(t *testing.T) { dynamoClient. ExpectOne(ctx, dynamo.OrganisationKey("a-uuid"), dynamo.MemberKey("session-id"), nil, expectedError) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.Get(ctx) assert.Equal(t, expectedError, err) @@ -339,7 +339,7 @@ func TestMemberStoreGetWhenErrors(t *testing.T) { func TestMemberStoreCreate(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{SessionID: "session-id", Email: "email@example.com"}) - expectedMember := &actor.Member{ + expectedMember := &supporterdata.Member{ PK: dynamo.OrganisationKey("a-uuid"), SK: dynamo.MemberKey("session-id"), CreatedAt: testNow, @@ -349,8 +349,8 @@ func TestMemberStoreCreate(t *testing.T) { Email: "email@example.com", FirstNames: "a", LastName: "b", - Permission: actor.PermissionAdmin, - Status: actor.StatusActive, + Permission: supporterdata.PermissionAdmin, + Status: supporterdata.StatusActive, LastLoggedInAt: testNow, } @@ -368,7 +368,7 @@ func TestMemberStoreCreate(t *testing.T) { Return(nil). Once() - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} member, err := memberStore.Create(ctx, "a", "b") assert.Nil(t, err) @@ -384,7 +384,7 @@ func TestMemberStoreCreateWhenSessionMissing(t *testing.T) { for name, ctx := range testCases { t.Run(name, func(t *testing.T) { - memberStore := &memberStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.Create(ctx, "a", "b") assert.Error(t, err) @@ -425,7 +425,7 @@ func TestMemberStoreCreateWhenDynamoErrors(t *testing.T) { dynamoClient := newMockDynamoClient(t) tc.dynamoClientSetup(dynamoClient) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.Create(ctx, "a", "b") assert.ErrorIs(t, err, expectedError) @@ -436,19 +436,19 @@ func TestMemberStoreCreateWhenDynamoErrors(t *testing.T) { func TestMemberStoreCreateFromInvite(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{SessionID: "session-id"}) - invite := &actor.MemberInvite{ + invite := &supporterdata.MemberInvite{ PK: "pk", SK: "sk", Email: "ab@example.org", FirstNames: "a", LastName: "b", - Permission: actor.PermissionAdmin, + Permission: supporterdata.PermissionAdmin, OrganisationID: "org-id", } dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). - Create(ctx, &actor.Member{ + Create(ctx, &supporterdata.Member{ PK: dynamo.OrganisationKey("org-id"), SK: dynamo.MemberKey("session-id"), CreatedAt: testNow, @@ -459,7 +459,7 @@ func TestMemberStoreCreateFromInvite(t *testing.T) { FirstNames: invite.FirstNames, LastName: invite.LastName, Permission: invite.Permission, - Status: actor.StatusActive, + Status: supporterdata.StatusActive, LastLoggedInAt: testNow, }). Return(nil) @@ -476,7 +476,7 @@ func TestMemberStoreCreateFromInvite(t *testing.T) { }). Return(nil) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} err := memberStore.CreateFromInvite(ctx, invite) assert.Nil(t, err) @@ -490,9 +490,9 @@ func TestMemberStoreCreateFromInviteWhenSessionMissing(t *testing.T) { for name, ctx := range testCases { t.Run(name, func(t *testing.T) { - memberStore := &memberStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} - err := memberStore.CreateFromInvite(ctx, &actor.MemberInvite{}) + err := memberStore.CreateFromInvite(ctx, &supporterdata.MemberInvite{}) assert.Error(t, err) }) } @@ -537,9 +537,9 @@ func TestMemberStoreCreateFromInviteWhenDynamoErrors(t *testing.T) { Return(tc.createLinkError). Once() } - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} - err := memberStore.CreateFromInvite(ctx, &actor.MemberInvite{}) + err := memberStore.CreateFromInvite(ctx, &supporterdata.MemberInvite{}) assert.Error(t, err) }) } @@ -557,7 +557,7 @@ func TestMemberStoreGetByID(t *testing.T) { MemberSK: dynamo.MemberKey("a-uuid"), }, nil) - expectedMember := &actor.Member{ + expectedMember := &supporterdata.Member{ PK: dynamo.OrganisationKey("org-id"), SK: dynamo.MemberKey("a-uuid"), ID: "1", @@ -567,7 +567,7 @@ func TestMemberStoreGetByID(t *testing.T) { ExpectOne(ctx, dynamo.OrganisationKey("org-id"), dynamo.MemberKey("a-uuid"), expectedMember, nil) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} member, err := memberStore.GetByID(ctx, "1") @@ -583,7 +583,7 @@ func TestMemberStoreGetByIDWhenMissingSession(t *testing.T) { for name, ctx := range testCases { t.Run(name, func(t *testing.T) { - memberStore := &memberStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.GetByID(ctx, "1") @@ -617,10 +617,10 @@ func TestMemberStoreGetByIDWhenDynamoClientErrors(t *testing.T) { if tc.oneMemberError != nil { dynamoClient. ExpectOne(mock.Anything, mock.Anything, mock.Anything, - &actor.Member{}, tc.oneMemberError) + &supporterdata.Member{}, tc.oneMemberError) } - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.GetByID(ctx, "1") @@ -632,14 +632,14 @@ func TestMemberStoreGetByIDWhenDynamoClientErrors(t *testing.T) { func TestMemberStoreGetAny(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{SessionID: "session-id"}) - expectedMember := &actor.Member{ID: "a"} + expectedMember := &supporterdata.Member{ID: "a"} dynamoClient := newMockDynamoClient(t) dynamoClient. ExpectOneBySK(ctx, dynamo.MemberKey("session-id"), expectedMember, nil) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} member, err := memberStore.GetAny(ctx) assert.Nil(t, err) @@ -654,7 +654,7 @@ func TestMemberStoreGetAnyWhenMissingSession(t *testing.T) { for name, ctx := range testCases { t.Run(name, func(t *testing.T) { - memberStore := &memberStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.GetAny(ctx) @@ -671,7 +671,7 @@ func TestMemberStoreGetAnyWhenDynamoClientErrors(t *testing.T) { ExpectOneBySK(ctx, dynamo.MemberKey("session-id"), nil, expectedError) - memberStore := &memberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + memberStore := &MemberStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := memberStore.GetAny(ctx) diff --git a/internal/supporter/mock_DynamoClient_test.go b/internal/supporter/mock_DynamoClient_test.go new file mode 100644 index 0000000000..c6aad63d1a --- /dev/null +++ b/internal/supporter/mock_DynamoClient_test.go @@ -0,0 +1,373 @@ +// Code generated by mockery v2.42.2. DO NOT EDIT. + +package supporter + +import ( + context "context" + + dynamo "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + mock "github.com/stretchr/testify/mock" +) + +// mockDynamoClient is an autogenerated mock type for the DynamoClient type +type mockDynamoClient struct { + mock.Mock +} + +type mockDynamoClient_Expecter struct { + mock *mock.Mock +} + +func (_m *mockDynamoClient) EXPECT() *mockDynamoClient_Expecter { + return &mockDynamoClient_Expecter{mock: &_m.Mock} +} + +// AllByPartialSK provides a mock function with given fields: ctx, pk, partialSK, v +func (_m *mockDynamoClient) AllByPartialSK(ctx context.Context, pk dynamo.PK, partialSK dynamo.SK, v interface{}) error { + ret := _m.Called(ctx, pk, partialSK, v) + + if len(ret) == 0 { + panic("no return value specified for AllByPartialSK") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dynamo.PK, dynamo.SK, interface{}) error); ok { + r0 = rf(ctx, pk, partialSK, v) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockDynamoClient_AllByPartialSK_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllByPartialSK' +type mockDynamoClient_AllByPartialSK_Call struct { + *mock.Call +} + +// AllByPartialSK is a helper method to define mock.On call +// - ctx context.Context +// - pk dynamo.PK +// - partialSK dynamo.SK +// - v interface{} +func (_e *mockDynamoClient_Expecter) AllByPartialSK(ctx interface{}, pk interface{}, partialSK interface{}, v interface{}) *mockDynamoClient_AllByPartialSK_Call { + return &mockDynamoClient_AllByPartialSK_Call{Call: _e.mock.On("AllByPartialSK", ctx, pk, partialSK, v)} +} + +func (_c *mockDynamoClient_AllByPartialSK_Call) Run(run func(ctx context.Context, pk dynamo.PK, partialSK dynamo.SK, v interface{})) *mockDynamoClient_AllByPartialSK_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dynamo.PK), args[2].(dynamo.SK), args[3].(interface{})) + }) + return _c +} + +func (_c *mockDynamoClient_AllByPartialSK_Call) Return(_a0 error) *mockDynamoClient_AllByPartialSK_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockDynamoClient_AllByPartialSK_Call) RunAndReturn(run func(context.Context, dynamo.PK, dynamo.SK, interface{}) error) *mockDynamoClient_AllByPartialSK_Call { + _c.Call.Return(run) + return _c +} + +// AllBySK provides a mock function with given fields: ctx, sk, v +func (_m *mockDynamoClient) AllBySK(ctx context.Context, sk dynamo.SK, v interface{}) error { + ret := _m.Called(ctx, sk, v) + + if len(ret) == 0 { + panic("no return value specified for AllBySK") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dynamo.SK, interface{}) error); ok { + r0 = rf(ctx, sk, v) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockDynamoClient_AllBySK_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllBySK' +type mockDynamoClient_AllBySK_Call struct { + *mock.Call +} + +// AllBySK is a helper method to define mock.On call +// - ctx context.Context +// - sk dynamo.SK +// - v interface{} +func (_e *mockDynamoClient_Expecter) AllBySK(ctx interface{}, sk interface{}, v interface{}) *mockDynamoClient_AllBySK_Call { + return &mockDynamoClient_AllBySK_Call{Call: _e.mock.On("AllBySK", ctx, sk, v)} +} + +func (_c *mockDynamoClient_AllBySK_Call) Run(run func(ctx context.Context, sk dynamo.SK, v interface{})) *mockDynamoClient_AllBySK_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dynamo.SK), args[2].(interface{})) + }) + return _c +} + +func (_c *mockDynamoClient_AllBySK_Call) Return(_a0 error) *mockDynamoClient_AllBySK_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockDynamoClient_AllBySK_Call) RunAndReturn(run func(context.Context, dynamo.SK, interface{}) error) *mockDynamoClient_AllBySK_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, v +func (_m *mockDynamoClient) Create(ctx context.Context, v interface{}) error { + ret := _m.Called(ctx, v) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, interface{}) error); ok { + r0 = rf(ctx, v) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockDynamoClient_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type mockDynamoClient_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - v interface{} +func (_e *mockDynamoClient_Expecter) Create(ctx interface{}, v interface{}) *mockDynamoClient_Create_Call { + return &mockDynamoClient_Create_Call{Call: _e.mock.On("Create", ctx, v)} +} + +func (_c *mockDynamoClient_Create_Call) Run(run func(ctx context.Context, v interface{})) *mockDynamoClient_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(interface{})) + }) + return _c +} + +func (_c *mockDynamoClient_Create_Call) Return(_a0 error) *mockDynamoClient_Create_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockDynamoClient_Create_Call) RunAndReturn(run func(context.Context, interface{}) error) *mockDynamoClient_Create_Call { + _c.Call.Return(run) + return _c +} + +// DeleteOne provides a mock function with given fields: ctx, pk, sk +func (_m *mockDynamoClient) DeleteOne(ctx context.Context, pk dynamo.PK, sk dynamo.SK) error { + ret := _m.Called(ctx, pk, sk) + + if len(ret) == 0 { + panic("no return value specified for DeleteOne") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dynamo.PK, dynamo.SK) error); ok { + r0 = rf(ctx, pk, sk) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockDynamoClient_DeleteOne_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteOne' +type mockDynamoClient_DeleteOne_Call struct { + *mock.Call +} + +// DeleteOne is a helper method to define mock.On call +// - ctx context.Context +// - pk dynamo.PK +// - sk dynamo.SK +func (_e *mockDynamoClient_Expecter) DeleteOne(ctx interface{}, pk interface{}, sk interface{}) *mockDynamoClient_DeleteOne_Call { + return &mockDynamoClient_DeleteOne_Call{Call: _e.mock.On("DeleteOne", ctx, pk, sk)} +} + +func (_c *mockDynamoClient_DeleteOne_Call) Run(run func(ctx context.Context, pk dynamo.PK, sk dynamo.SK)) *mockDynamoClient_DeleteOne_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dynamo.PK), args[2].(dynamo.SK)) + }) + return _c +} + +func (_c *mockDynamoClient_DeleteOne_Call) Return(_a0 error) *mockDynamoClient_DeleteOne_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockDynamoClient_DeleteOne_Call) RunAndReturn(run func(context.Context, dynamo.PK, dynamo.SK) error) *mockDynamoClient_DeleteOne_Call { + _c.Call.Return(run) + return _c +} + +// One provides a mock function with given fields: ctx, pk, sk, v +func (_m *mockDynamoClient) One(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { + ret := _m.Called(ctx, pk, sk, v) + + if len(ret) == 0 { + panic("no return value specified for One") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dynamo.PK, dynamo.SK, interface{}) error); ok { + r0 = rf(ctx, pk, sk, v) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockDynamoClient_One_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'One' +type mockDynamoClient_One_Call struct { + *mock.Call +} + +// One is a helper method to define mock.On call +// - ctx context.Context +// - pk dynamo.PK +// - sk dynamo.SK +// - v interface{} +func (_e *mockDynamoClient_Expecter) One(ctx interface{}, pk interface{}, sk interface{}, v interface{}) *mockDynamoClient_One_Call { + return &mockDynamoClient_One_Call{Call: _e.mock.On("One", ctx, pk, sk, v)} +} + +func (_c *mockDynamoClient_One_Call) Run(run func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{})) *mockDynamoClient_One_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dynamo.PK), args[2].(dynamo.SK), args[3].(interface{})) + }) + return _c +} + +func (_c *mockDynamoClient_One_Call) Return(_a0 error) *mockDynamoClient_One_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockDynamoClient_One_Call) RunAndReturn(run func(context.Context, dynamo.PK, dynamo.SK, interface{}) error) *mockDynamoClient_One_Call { + _c.Call.Return(run) + return _c +} + +// OneBySK provides a mock function with given fields: ctx, sk, v +func (_m *mockDynamoClient) OneBySK(ctx context.Context, sk dynamo.SK, v interface{}) error { + ret := _m.Called(ctx, sk, v) + + if len(ret) == 0 { + panic("no return value specified for OneBySK") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dynamo.SK, interface{}) error); ok { + r0 = rf(ctx, sk, v) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockDynamoClient_OneBySK_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OneBySK' +type mockDynamoClient_OneBySK_Call struct { + *mock.Call +} + +// OneBySK is a helper method to define mock.On call +// - ctx context.Context +// - sk dynamo.SK +// - v interface{} +func (_e *mockDynamoClient_Expecter) OneBySK(ctx interface{}, sk interface{}, v interface{}) *mockDynamoClient_OneBySK_Call { + return &mockDynamoClient_OneBySK_Call{Call: _e.mock.On("OneBySK", ctx, sk, v)} +} + +func (_c *mockDynamoClient_OneBySK_Call) Run(run func(ctx context.Context, sk dynamo.SK, v interface{})) *mockDynamoClient_OneBySK_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dynamo.SK), args[2].(interface{})) + }) + return _c +} + +func (_c *mockDynamoClient_OneBySK_Call) Return(_a0 error) *mockDynamoClient_OneBySK_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockDynamoClient_OneBySK_Call) RunAndReturn(run func(context.Context, dynamo.SK, interface{}) error) *mockDynamoClient_OneBySK_Call { + _c.Call.Return(run) + return _c +} + +// Put provides a mock function with given fields: ctx, v +func (_m *mockDynamoClient) Put(ctx context.Context, v interface{}) error { + ret := _m.Called(ctx, v) + + if len(ret) == 0 { + panic("no return value specified for Put") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, interface{}) error); ok { + r0 = rf(ctx, v) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockDynamoClient_Put_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Put' +type mockDynamoClient_Put_Call struct { + *mock.Call +} + +// Put is a helper method to define mock.On call +// - ctx context.Context +// - v interface{} +func (_e *mockDynamoClient_Expecter) Put(ctx interface{}, v interface{}) *mockDynamoClient_Put_Call { + return &mockDynamoClient_Put_Call{Call: _e.mock.On("Put", ctx, v)} +} + +func (_c *mockDynamoClient_Put_Call) Run(run func(ctx context.Context, v interface{})) *mockDynamoClient_Put_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(interface{})) + }) + return _c +} + +func (_c *mockDynamoClient_Put_Call) Return(_a0 error) *mockDynamoClient_Put_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockDynamoClient_Put_Call) RunAndReturn(run func(context.Context, interface{}) error) *mockDynamoClient_Put_Call { + _c.Call.Return(run) + return _c +} + +// newMockDynamoClient creates a new instance of mockDynamoClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newMockDynamoClient(t interface { + mock.TestingT + Cleanup(func()) +}) *mockDynamoClient { + mock := &mockDynamoClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/supporter/mock_test.go b/internal/supporter/mock_test.go new file mode 100644 index 0000000000..f418960016 --- /dev/null +++ b/internal/supporter/mock_test.go @@ -0,0 +1,62 @@ +package supporter + +import ( + "context" + "encoding/json" + "errors" + "time" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" + "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + "github.com/stretchr/testify/mock" +) + +var ( + ctx = context.Background() + expectedError = errors.New("err") + testNow = time.Date(2023, time.April, 2, 3, 4, 5, 6, time.UTC) + testNowFn = func() time.Time { return testNow } + testUID = actoruid.New() + testUIDFn = func() actoruid.UID { return testUID } +) + +func (m *mockDynamoClient) ExpectOne(ctx, pk, sk, data interface{}, err error) { + m. + On("One", ctx, pk, sk, mock.Anything). + Return(func(ctx context.Context, pk dynamo.PK, partialSk dynamo.SK, v interface{}) error { + b, _ := json.Marshal(data) + json.Unmarshal(b, v) + return err + }). + Once() +} + +func (m *mockDynamoClient) ExpectAllByPartialSK(ctx, pk, partialSk, data interface{}, err error) { + m. + On("AllByPartialSK", ctx, pk, partialSk, mock.Anything). + Return(func(ctx context.Context, pk dynamo.PK, partialSk dynamo.SK, v interface{}) error { + b, _ := json.Marshal(data) + json.Unmarshal(b, v) + return err + }) +} + +func (m *mockDynamoClient) ExpectAllBySK(ctx, sk, data interface{}, err error) { + m. + On("AllBySK", ctx, sk, mock.Anything). + Return(func(ctx context.Context, sk dynamo.SK, v interface{}) error { + b, _ := json.Marshal(data) + json.Unmarshal(b, v) + return err + }) +} + +func (m *mockDynamoClient) ExpectOneBySK(ctx, sk, data interface{}, err error) { + m. + On("OneBySK", ctx, sk, mock.Anything). + Return(func(ctx context.Context, sk dynamo.SK, v interface{}) error { + b, _ := json.Marshal(data) + json.Unmarshal(b, v) + return err + }) +} diff --git a/internal/app/organisation_store.go b/internal/supporter/organisation_store.go similarity index 71% rename from internal/app/organisation_store.go rename to internal/supporter/organisation_store.go index 89489c3413..4c897b8f03 100644 --- a/internal/app/organisation_store.go +++ b/internal/supporter/organisation_store.go @@ -1,4 +1,4 @@ -package app +package supporter import ( "context" @@ -6,14 +6,15 @@ import ( "fmt" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + "github.com/ministryofjustice/opg-modernising-lpa/internal/random" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" ) -type organisationStore struct { +type OrganisationStore struct { dynamoClient DynamoClient uuidString func() string newUID func() actoruid.UID @@ -21,6 +22,16 @@ type organisationStore struct { now func() time.Time } +func NewOrganisationStore(dynamoClient DynamoClient) *OrganisationStore { + return &OrganisationStore{ + dynamoClient: dynamoClient, + uuidString: random.UuidString, + newUID: actoruid.New, + randomString: random.String, + now: time.Now, + } +} + // An organisationLink is used to join a Member to an Organisation to be accessed by MemberID. type organisationLink struct { // PK is the same as the PK for the Member @@ -30,7 +41,7 @@ type organisationLink struct { MemberSK dynamo.MemberKeyType } -func (s *organisationStore) Create(ctx context.Context, member *actor.Member, name string) (*actor.Organisation, error) { +func (s *OrganisationStore) Create(ctx context.Context, member *supporterdata.Member, name string) (*supporterdata.Organisation, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -40,7 +51,7 @@ func (s *organisationStore) Create(ctx context.Context, member *actor.Member, na return nil, errors.New("organisationStore.Create requires SessionID") } - organisation := &actor.Organisation{ + organisation := &supporterdata.Organisation{ PK: dynamo.OrganisationKey(member.OrganisationID), SK: dynamo.OrganisationKey(member.OrganisationID), ID: member.OrganisationID, @@ -55,7 +66,7 @@ func (s *organisationStore) Create(ctx context.Context, member *actor.Member, na return organisation, nil } -func (s *organisationStore) Get(ctx context.Context) (*actor.Organisation, error) { +func (s *OrganisationStore) Get(ctx context.Context) (*supporterdata.Organisation, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -65,12 +76,12 @@ func (s *organisationStore) Get(ctx context.Context) (*actor.Organisation, error return nil, errors.New("organisationStore.Get requires SessionID") } - var member actor.Member + var member supporterdata.Member if err := s.dynamoClient.OneBySK(ctx, dynamo.MemberKey(data.SessionID), &member); err != nil { return nil, err } - var organisation actor.Organisation + var organisation supporterdata.Organisation if err := s.dynamoClient.One(ctx, member.PK, member.PK, &organisation); err != nil { return nil, err } @@ -82,12 +93,12 @@ func (s *organisationStore) Get(ctx context.Context) (*actor.Organisation, error return &organisation, err } -func (s *organisationStore) Put(ctx context.Context, organisation *actor.Organisation) error { +func (s *OrganisationStore) Put(ctx context.Context, organisation *supporterdata.Organisation) error { organisation.UpdatedAt = s.now() return s.dynamoClient.Put(ctx, organisation) } -func (s *organisationStore) CreateLPA(ctx context.Context) (*donordata.Provided, error) { +func (s *OrganisationStore) CreateLPA(ctx context.Context) (*donordata.Provided, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err @@ -122,7 +133,7 @@ func (s *organisationStore) CreateLPA(ctx context.Context) (*donordata.Provided, return donor, err } -func (s *organisationStore) SoftDelete(ctx context.Context, organisation *actor.Organisation) error { +func (s *OrganisationStore) SoftDelete(ctx context.Context, organisation *supporterdata.Organisation) error { organisation.DeletedAt = s.now() return s.dynamoClient.Put(ctx, organisation) diff --git a/internal/app/organisation_store_test.go b/internal/supporter/organisation_store_test.go similarity index 77% rename from internal/app/organisation_store_test.go rename to internal/supporter/organisation_store_test.go index 62133a6180..92b6027bf2 100644 --- a/internal/app/organisation_store_test.go +++ b/internal/supporter/organisation_store_test.go @@ -1,13 +1,13 @@ -package app +package supporter import ( "context" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/stretchr/testify/assert" mock "github.com/stretchr/testify/mock" ) @@ -17,7 +17,7 @@ func TestOrganisationStoreCreate(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). - Create(ctx, &actor.Organisation{ + Create(ctx, &supporterdata.Organisation{ PK: dynamo.OrganisationKey("a-uuid"), SK: dynamo.OrganisationKey("a-uuid"), ID: "a-uuid", @@ -26,11 +26,11 @@ func TestOrganisationStoreCreate(t *testing.T) { }). Return(nil) - organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + organisationStore := &OrganisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} - organisation, err := organisationStore.Create(ctx, &actor.Member{OrganisationID: "a-uuid"}, "A name") + organisation, err := organisationStore.Create(ctx, &supporterdata.Member{OrganisationID: "a-uuid"}, "A name") assert.Nil(t, err) - assert.Equal(t, &actor.Organisation{ + assert.Equal(t, &supporterdata.Organisation{ PK: dynamo.OrganisationKey("a-uuid"), SK: dynamo.OrganisationKey("a-uuid"), ID: "a-uuid", @@ -47,9 +47,9 @@ func TestOrganisationStoreCreateWithSessionMissing(t *testing.T) { for name, ctx := range testcases { t.Run(name, func(t *testing.T) { - organisationStore := &organisationStore{} + organisationStore := &OrganisationStore{} - organisation, err := organisationStore.Create(ctx, &actor.Member{OrganisationID: "a-uuid"}, "A name") + organisation, err := organisationStore.Create(ctx, &supporterdata.Member{OrganisationID: "a-uuid"}, "A name") assert.Error(t, err) assert.Nil(t, organisation) }) @@ -64,25 +64,25 @@ func TestOrganisationStoreCreateWhenErrors(t *testing.T) { Create(ctx, mock.Anything). Return(expectedError) - organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + organisationStore := &OrganisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} - organisation, err := organisationStore.Create(ctx, &actor.Member{OrganisationID: "a-uuid"}, "A name") + organisation, err := organisationStore.Create(ctx, &supporterdata.Member{OrganisationID: "a-uuid"}, "A name") assert.ErrorIs(t, err, expectedError) assert.Nil(t, organisation) } func TestOrganisationStoreGet(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{SessionID: "session-id"}) - organisation := &actor.Organisation{Name: "A name"} + organisation := &supporterdata.Organisation{Name: "A name"} - member := actor.Member{PK: dynamo.OrganisationKey("a-uuid")} + member := supporterdata.Member{PK: dynamo.OrganisationKey("a-uuid")} dynamoClient := newMockDynamoClient(t) dynamoClient. ExpectOneBySK(ctx, dynamo.MemberKey("session-id"), member, nil) dynamoClient. ExpectOne(ctx, dynamo.OrganisationKey("a-uuid"), dynamo.OrganisationKey("a-uuid"), organisation, nil) - organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + organisationStore := &OrganisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} result, err := organisationStore.Get(ctx) assert.Nil(t, err) @@ -91,16 +91,16 @@ func TestOrganisationStoreGet(t *testing.T) { func TestOrganisationStoreGetWhenOrganisationDeleted(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{SessionID: "session-id"}) - organisation := &actor.Organisation{Name: "A name", DeletedAt: testNow} + organisation := &supporterdata.Organisation{Name: "A name", DeletedAt: testNow} - member := actor.Member{PK: dynamo.OrganisationKey("a-uuid")} + member := supporterdata.Member{PK: dynamo.OrganisationKey("a-uuid")} dynamoClient := newMockDynamoClient(t) dynamoClient. ExpectOneBySK(ctx, dynamo.MemberKey("session-id"), member, nil) dynamoClient. ExpectOne(ctx, dynamo.OrganisationKey("a-uuid"), dynamo.OrganisationKey("a-uuid"), organisation, nil) - organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + organisationStore := &OrganisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} result, err := organisationStore.Get(ctx) @@ -116,7 +116,7 @@ func TestOrganisationStoreGetWithSessionErrors(t *testing.T) { for name, ctx := range testcases { t.Run(name, func(t *testing.T) { - organisationStore := &organisationStore{} + organisationStore := &OrganisationStore{} _, err := organisationStore.Get(ctx) assert.Error(t, err) @@ -138,7 +138,7 @@ func TestOrganisationStoreGetWhenErrors(t *testing.T) { } ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{SessionID: "session-id"}) - member := actor.Member{PK: dynamo.OrganisationKey("a-uuid")} + member := supporterdata.Member{PK: dynamo.OrganisationKey("a-uuid")} for name, tc := range testcases { t.Run(name, func(t *testing.T) { @@ -151,7 +151,7 @@ func TestOrganisationStoreGetWhenErrors(t *testing.T) { ExpectOne(ctx, dynamo.OrganisationKey("a-uuid"), dynamo.OrganisationKey("a-uuid"), nil, tc.oneError) } - organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + organisationStore := &OrganisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := organisationStore.Get(ctx) assert.Equal(t, expectedError, err) @@ -164,15 +164,15 @@ func TestOrganisationStorePut(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). - Put(ctx, &actor.Organisation{PK: dynamo.OrganisationKey("123"), SK: dynamo.OrganisationKey("456"), Name: "Hey", UpdatedAt: testNow}). + Put(ctx, &supporterdata.Organisation{PK: dynamo.OrganisationKey("123"), SK: dynamo.OrganisationKey("456"), Name: "Hey", UpdatedAt: testNow}). Return(expectedError) - store := &organisationStore{ + store := &OrganisationStore{ dynamoClient: dynamoClient, now: testNowFn, } - err := store.Put(ctx, &actor.Organisation{PK: dynamo.OrganisationKey("123"), SK: dynamo.OrganisationKey("456"), Name: "Hey"}) + err := store.Put(ctx, &supporterdata.Organisation{PK: dynamo.OrganisationKey("123"), SK: dynamo.OrganisationKey("456"), Name: "Hey"}) assert.Equal(t, expectedError, err) } @@ -195,7 +195,7 @@ func TestOrganisationStoreCreateLPA(t *testing.T) { Create(ctx, expectedDonor). Return(nil) - organisationStore := &organisationStore{ + organisationStore := &OrganisationStore{ dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }, @@ -216,7 +216,7 @@ func TestOrganisationStoreCreateLPAWithSessionMissing(t *testing.T) { for name, ctx := range testCases { t.Run(name, func(t *testing.T) { - organisationStore := &organisationStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} + organisationStore := &OrganisationStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} _, err := organisationStore.CreateLPA(ctx) assert.Error(t, err) @@ -232,7 +232,7 @@ func TestOrganisationStoreCreateLPAWhenDynamoError(t *testing.T) { Create(ctx, mock.Anything). Return(expectedError) - organisationStore := &organisationStore{ + organisationStore := &OrganisationStore{ dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }, @@ -249,12 +249,12 @@ func TestOrganisationStoreSoftDelete(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). - Put(ctx, &actor.Organisation{DeletedAt: testNow}). + Put(ctx, &supporterdata.Organisation{DeletedAt: testNow}). Return(nil) - organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + organisationStore := &OrganisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} - err := organisationStore.SoftDelete(ctx, &actor.Organisation{}) + err := organisationStore.SoftDelete(ctx, &supporterdata.Organisation{}) assert.Nil(t, err) } @@ -266,8 +266,8 @@ func TestOrganisationStoreSoftDeleteWhenDynamoClientError(t *testing.T) { Put(mock.Anything, mock.Anything). Return(expectedError) - organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} + organisationStore := &OrganisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} - err := organisationStore.SoftDelete(ctx, &actor.Organisation{}) + err := organisationStore.SoftDelete(ctx, &supporterdata.Organisation{}) assert.Error(t, err) } diff --git a/internal/actor/enum_permission.go b/internal/supporter/supporterdata/enum_permission.go similarity index 98% rename from internal/actor/enum_permission.go rename to internal/supporter/supporterdata/enum_permission.go index a058ee9e27..0ae9c54992 100644 --- a/internal/actor/enum_permission.go +++ b/internal/supporter/supporterdata/enum_permission.go @@ -1,6 +1,6 @@ // Code generated by "enumerator -type Permission -linecomment -trimprefix"; DO NOT EDIT. -package actor +package supporterdata import ( "fmt" diff --git a/internal/actor/enum_status.go b/internal/supporter/supporterdata/enum_status.go similarity index 98% rename from internal/actor/enum_status.go rename to internal/supporter/supporterdata/enum_status.go index b688a7f5c8..020739f021 100644 --- a/internal/actor/enum_status.go +++ b/internal/supporter/supporterdata/enum_status.go @@ -1,6 +1,6 @@ // Code generated by "enumerator -type Status -linecomment -trimprefix"; DO NOT EDIT. -package actor +package supporterdata import ( "fmt" diff --git a/internal/supporter/supporterdata/member.go b/internal/supporter/supporterdata/member.go new file mode 100644 index 0000000000..faa9e6a35d --- /dev/null +++ b/internal/supporter/supporterdata/member.go @@ -0,0 +1,35 @@ +package supporterdata + +import ( + "fmt" + "time" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" +) + +// A Member is the association of a OneLogin user with an Organisation. +type Member struct { + PK dynamo.OrganisationKeyType + SK dynamo.MemberKeyType + // CreatedAt is when the Member was created + CreatedAt time.Time + // UpdatedAt is when the Member was last updated + UpdatedAt time.Time + // ID is a unique identifier for the Member + ID string + // OrganisationID identifies the organisation the member belongs to + OrganisationID string + Email string + FirstNames string + LastName string + // Permission is the type of permissions assigned to the member to set available actions in an Organisation + Permission Permission + // Status controls access to the Organisation + Status Status + // LastLoggedInAt is when the Member last logged in to the service + LastLoggedInAt time.Time +} + +func (i Member) FullName() string { + return fmt.Sprintf("%s %s", i.FirstNames, i.LastName) +} diff --git a/internal/supporter/supporterdata/member_invite.go b/internal/supporter/supporterdata/member_invite.go new file mode 100644 index 0000000000..165a1f007f --- /dev/null +++ b/internal/supporter/supporterdata/member_invite.go @@ -0,0 +1,40 @@ +package supporterdata + +import ( + "fmt" + "time" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" +) + +const memberInviteExpireAfter = time.Hour * 48 + +// A MemberInvite is created to allow a new Member to join an Organisation +type MemberInvite struct { + PK dynamo.OrganisationKeyType + SK dynamo.MemberInviteKeyType + // CreatedAt is when the MemberInvite was created + CreatedAt time.Time + // UpdatedAt is when the MemberInvite was last updated + UpdatedAt time.Time + // OrganisationID identifies the organisation the invite is for + OrganisationID string + // OrganisationName is the name of the organisation the invite is for + OrganisationName string + // Email is the address the new Member must sign in as for the invite + Email string + FirstNames string + LastName string + // Permission is the type of permissions assigned to the member to set available actions in an Organisation + Permission Permission + // ReferenceNumber is a unique code used to invite a Member to and Organisation + ReferenceNumber string +} + +func (i MemberInvite) HasExpired() bool { + return i.CreatedAt.Add(memberInviteExpireAfter).Before(time.Now()) +} + +func (i MemberInvite) FullName() string { + return fmt.Sprintf("%s %s", i.FirstNames, i.LastName) +} diff --git a/internal/supporter/supporterdata/organisation.go b/internal/supporter/supporterdata/organisation.go new file mode 100644 index 0000000000..d1ea9e3e84 --- /dev/null +++ b/internal/supporter/supporterdata/organisation.go @@ -0,0 +1,23 @@ +package supporterdata + +import ( + "time" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" +) + +// An Organisation contains users associated with a set of permissions that work on the +// same set of LPAs. +type Organisation struct { + PK, SK dynamo.OrganisationKeyType + // CreatedAt is when the Organisation was created + CreatedAt time.Time + // UpdatedAt is when the Organisation was last updated + UpdatedAt time.Time + // DeletedAt is when the Organisation was (soft) deleted + DeletedAt time.Time + // ID is a unique identifier for the Organisation + ID string + // Name of the Organisation, this is unique across all Organisations + Name string +} diff --git a/internal/actor/organisation_test.go b/internal/supporter/supporterdata/organisation_test.go similarity index 96% rename from internal/actor/organisation_test.go rename to internal/supporter/supporterdata/organisation_test.go index 1e18c7fef2..e26853ad36 100644 --- a/internal/actor/organisation_test.go +++ b/internal/supporter/supporterdata/organisation_test.go @@ -1,4 +1,4 @@ -package actor +package supporterdata import ( "fmt" diff --git a/internal/actor/permission.go b/internal/supporter/supporterdata/permission.go similarity index 89% rename from internal/actor/permission.go rename to internal/supporter/supporterdata/permission.go index ae92d290d7..2befcf23fc 100644 --- a/internal/actor/permission.go +++ b/internal/supporter/supporterdata/permission.go @@ -1,4 +1,4 @@ -package actor +package supporterdata //go:generate enumerator -type Permission -linecomment -trimprefix type Permission uint8 diff --git a/internal/actor/status.go b/internal/supporter/supporterdata/status.go similarity index 89% rename from internal/actor/status.go rename to internal/supporter/supporterdata/status.go index 36d070980c..54bc87f4a8 100644 --- a/internal/actor/status.go +++ b/internal/supporter/supporterdata/status.go @@ -1,4 +1,4 @@ -package actor +package supporterdata //go:generate enumerator -type Status -linecomment -trimprefix type Status uint8 diff --git a/internal/page/supporter/confirm_donor_can_interact_online.go b/internal/supporter/supporterpage/confirm_donor_can_interact_online.go similarity index 86% rename from internal/page/supporter/confirm_donor_can_interact_online.go rename to internal/supporter/supporterpage/confirm_donor_can_interact_online.go index 677c683163..9143e8b6c5 100644 --- a/internal/page/supporter/confirm_donor_can_interact_online.go +++ b/internal/supporter/supporterpage/confirm_donor_can_interact_online.go @@ -1,13 +1,13 @@ -package supporter +package supporterpage import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -18,7 +18,7 @@ type confirmDonorCanInteractOnlineData struct { } func ConfirmDonorCanInteractOnline(tmpl template.Template, organisationStore OrganisationStore) Handler { - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { data := &confirmDonorCanInteractOnlineData{ App: appData, Form: form.NewYesNoForm(form.YesNoUnknown), diff --git a/internal/page/supporter/confirm_donor_can_interact_online_test.go b/internal/supporter/supporterpage/confirm_donor_can_interact_online_test.go similarity index 91% rename from internal/page/supporter/confirm_donor_can_interact_online_test.go rename to internal/supporter/supporterpage/confirm_donor_can_interact_online_test.go index 8bcc03ceb6..32eb33cff6 100644 --- a/internal/page/supporter/confirm_donor_can_interact_online_test.go +++ b/internal/supporter/supporterpage/confirm_donor_can_interact_online_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "net/http" @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -47,7 +47,7 @@ func TestPostConfirmDonorCanInteractOnlineWhenYes(t *testing.T) { CreateLPA(r.Context()). Return(&donordata.Provided{LpaID: "lpa-id"}, nil) - err := ConfirmDonorCanInteractOnline(nil, organisationStore)(testAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) + err := ConfirmDonorCanInteractOnline(nil, organisationStore)(testAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, nil) resp := w.Result() assert.Nil(t, err) @@ -62,7 +62,7 @@ func TestPostConfirmDonorCanInteractOnlineWhenNo(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := ConfirmDonorCanInteractOnline(nil, nil)(testAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) + err := ConfirmDonorCanInteractOnline(nil, nil)(testAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, nil) resp := w.Result() assert.Nil(t, err) @@ -84,7 +84,7 @@ func TestPostConfirmDonorCanInteractOnlineWhenValidationError(t *testing.T) { })). Return(nil) - err := ConfirmDonorCanInteractOnline(template.Execute, nil)(testAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) + err := ConfirmDonorCanInteractOnline(template.Execute, nil)(testAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, nil) resp := w.Result() assert.Nil(t, err) @@ -103,7 +103,7 @@ func TestPostConfirmDonorCanInteractOnlineWhenOrganisationStoreError(t *testing. CreateLPA(r.Context()). Return(&donordata.Provided{}, expectedError) - err := ConfirmDonorCanInteractOnline(nil, organisationStore)(testAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) + err := ConfirmDonorCanInteractOnline(nil, organisationStore)(testAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, nil) resp := w.Result() assert.Equal(t, expectedError, err) diff --git a/internal/page/supporter/dashboard.go b/internal/supporter/supporterpage/dashboard.go similarity index 87% rename from internal/page/supporter/dashboard.go rename to internal/supporter/supporterpage/dashboard.go index 8b70c51c53..d376f50c69 100644 --- a/internal/page/supporter/dashboard.go +++ b/internal/supporter/supporterpage/dashboard.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "context" @@ -6,10 +6,10 @@ import ( "strconv" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -29,7 +29,7 @@ type dashboardData struct { func Dashboard(tmpl template.Template, donorStore DonorStore, searchClient SearchClient) Handler { const pageSize = 10 - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { page, err := strconv.Atoi(r.FormValue("page")) if err != nil { page = 1 diff --git a/internal/page/supporter/dashboard_test.go b/internal/supporter/supporterpage/dashboard_test.go similarity index 99% rename from internal/page/supporter/dashboard_test.go rename to internal/supporter/supporterpage/dashboard_test.go index ae7187f8f4..56bea75448 100644 --- a/internal/page/supporter/dashboard_test.go +++ b/internal/supporter/supporterpage/dashboard_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "net/http" diff --git a/internal/page/supporter/delete_organisation.go b/internal/supporter/supporterpage/delete_organisation.go similarity index 88% rename from internal/page/supporter/delete_organisation.go rename to internal/supporter/supporterpage/delete_organisation.go index 37f021341b..25e7bd0400 100644 --- a/internal/page/supporter/delete_organisation.go +++ b/internal/supporter/supporterpage/delete_organisation.go @@ -1,14 +1,14 @@ -package supporter +package supporterpage import ( "net/http" "net/url" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -19,7 +19,7 @@ type deleteOrganisationData struct { } func DeleteOrganisation(logger Logger, tmpl template.Template, organisationStore OrganisationStore, sessionStore SessionStore, searchClient SearchClient) Handler { - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { if r.Method == http.MethodPost { if err := organisationStore.SoftDelete(r.Context(), organisation); err != nil { return err diff --git a/internal/page/supporter/delete_organisation_test.go b/internal/supporter/supporterpage/delete_organisation_test.go similarity index 87% rename from internal/page/supporter/delete_organisation_test.go rename to internal/supporter/supporterpage/delete_organisation_test.go index 88a892092b..1acafbf1a0 100644 --- a/internal/page/supporter/delete_organisation_test.go +++ b/internal/supporter/supporterpage/delete_organisation_test.go @@ -1,13 +1,13 @@ -package supporter +package supporterpage import ( "net/http" "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -29,7 +29,7 @@ func TestGetDeleteOrganisationName(t *testing.T) { }). Return(nil) - err := DeleteOrganisation(nil, template.Execute, nil, nil, searchClient)(testAppData, w, r, &actor.Organisation{}, nil) + err := DeleteOrganisation(nil, template.Execute, nil, nil, searchClient)(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() assert.Nil(t, err) @@ -45,7 +45,7 @@ func TestGetDeleteOrganisationNameWhenOrganisationStoreError(t *testing.T) { CountWithQuery(r.Context(), search.CountWithQueryReq{MustNotExist: "RegisteredAt"}). Return(0, expectedError) - err := DeleteOrganisation(nil, nil, nil, nil, searchClient)(testAppData, w, r, &actor.Organisation{}, nil) + err := DeleteOrganisation(nil, nil, nil, nil, searchClient)(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() assert.Error(t, err) @@ -66,7 +66,7 @@ func TestGetDeleteOrganisationNameWhenTemplateError(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := DeleteOrganisation(nil, template.Execute, nil, nil, searchClient)(testAppData, w, r, &actor.Organisation{}, nil) + err := DeleteOrganisation(nil, template.Execute, nil, nil, searchClient)(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() assert.Error(t, err) @@ -84,14 +84,14 @@ func TestPostDeleteOrganisationName(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). - SoftDelete(r.Context(), &actor.Organisation{}). + SoftDelete(r.Context(), &supporterdata.Organisation{}). Return(nil) logger := newMockLogger(t) logger.EXPECT(). InfoContext(r.Context(), "organisation deleted") - err := DeleteOrganisation(logger, nil, organisationStore, sessionStore, nil)(testOrgMemberAppData, w, r, &actor.Organisation{}, nil) + err := DeleteOrganisation(logger, nil, organisationStore, sessionStore, nil)(testOrgMemberAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() assert.Nil(t, err) @@ -117,7 +117,7 @@ func TestPostDeleteOrganisationNameWhenSessionStoreErrors(t *testing.T) { logger.EXPECT(). InfoContext(mock.Anything, mock.Anything) - err := DeleteOrganisation(logger, nil, organisationStore, sessionStore, nil)(testOrgMemberAppData, w, r, &actor.Organisation{}, nil) + err := DeleteOrganisation(logger, nil, organisationStore, sessionStore, nil)(testOrgMemberAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() assert.Error(t, err) @@ -134,7 +134,7 @@ func TestPostDeleteOrganisationNameWhenOrganisationStoreErrors(t *testing.T) { SoftDelete(mock.Anything, mock.Anything). Return(expectedError) - err := DeleteOrganisation(nil, nil, organisationStore, nil, nil)(testOrgMemberAppData, w, r, &actor.Organisation{}, nil) + err := DeleteOrganisation(nil, nil, organisationStore, nil, nil)(testOrgMemberAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() assert.Error(t, err) diff --git a/internal/page/supporter/donor_access.go b/internal/supporter/supporterpage/donor_access.go similarity index 95% rename from internal/page/supporter/donor_access.go rename to internal/supporter/supporterpage/donor_access.go index 90137ada2c..8651674aa0 100644 --- a/internal/page/supporter/donor_access.go +++ b/internal/supporter/supporterpage/donor_access.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "errors" @@ -7,7 +7,6 @@ import ( "net/url" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" @@ -15,6 +14,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -27,7 +27,7 @@ type donorAccessData struct { } func DonorAccess(logger Logger, tmpl template.Template, donorStore DonorStore, shareCodeStore ShareCodeStore, notifyClient NotifyClient, appPublicURL string, randomString func(int) string) Handler { - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, member *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, member *supporterdata.Member) error { donor, err := donorStore.Get(r.Context()) if err != nil { return err diff --git a/internal/page/supporter/donor_access_test.go b/internal/supporter/supporterpage/donor_access_test.go similarity index 92% rename from internal/page/supporter/donor_access_test.go rename to internal/supporter/supporterpage/donor_access_test.go index 30dc68c9a4..c93831f4af 100644 --- a/internal/page/supporter/donor_access_test.go +++ b/internal/supporter/supporterpage/donor_access_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "log/slog" @@ -8,7 +8,6 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" @@ -16,6 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" @@ -162,7 +162,7 @@ func TestPostDonorAccess(t *testing.T) { Return("Translation") testLpaAppData.Localizer = localizer - err := DonorAccess(nil, nil, donorStore, shareCodeStore, notifyClient, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &actor.Organisation{PK: dynamo.OrganisationKey("org-id"), ID: "org-id", Name: "Helpers"}, &actor.Member{FirstNames: "John", LastName: "Smith"}) + err := DonorAccess(nil, nil, donorStore, shareCodeStore, notifyClient, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &supporterdata.Organisation{PK: dynamo.OrganisationKey("org-id"), ID: "org-id", Name: "Helpers"}, &supporterdata.Member{FirstNames: "John", LastName: "Smith"}) resp := w.Result() assert.Nil(t, err) @@ -190,7 +190,7 @@ func TestPostDonorAccessWhenDonorUpdateErrors(t *testing.T) { GetDonor(r.Context()). Return(sharecode.Data{}, dynamo.NotFoundError{}) - err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "", nil)(testLpaAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) + err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "", nil)(testLpaAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, nil) assert.Equal(t, expectedError, err) } @@ -214,7 +214,7 @@ func TestPostDonorAccessWhenShareCodeStoreErrors(t *testing.T) { PutDonor(r.Context(), mock.Anything, mock.Anything). Return(expectedError) - err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "", testRandomStringFn)(testLpaAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) + err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "", testRandomStringFn)(testLpaAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, nil) assert.Equal(t, expectedError, err) } @@ -249,7 +249,7 @@ func TestPostDonorAccessWhenNotifyErrors(t *testing.T) { Return("Translation") testLpaAppData.Localizer = localizer - err := DonorAccess(nil, nil, donorStore, shareCodeStore, notifyClient, "", testRandomStringFn)(testLpaAppData, w, r, &actor.Organisation{ID: "org-id"}, &actor.Member{}) + err := DonorAccess(nil, nil, donorStore, shareCodeStore, notifyClient, "", testRandomStringFn)(testLpaAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, &supporterdata.Member{}) assert.Equal(t, expectedError, err) } @@ -277,7 +277,7 @@ func TestPostDonorAccessWhenValidationError(t *testing.T) { })). Return(nil) - err := DonorAccess(nil, template.Execute, donorStore, shareCodeStore, nil, "", nil)(testLpaAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) + err := DonorAccess(nil, template.Execute, donorStore, shareCodeStore, nil, "", nil)(testLpaAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, nil) resp := w.Result() assert.Nil(t, err) @@ -306,7 +306,7 @@ func TestPostDonorAccessRecall(t *testing.T) { Delete(r.Context(), shareCodeData). Return(nil) - err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &actor.Organisation{}, &actor.Member{}) + err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) resp := w.Result() assert.Nil(t, err) @@ -336,7 +336,7 @@ func TestPostDonorAccessRecallWhenDeleteErrors(t *testing.T) { Delete(r.Context(), shareCodeData). Return(expectedError) - err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &actor.Organisation{}, &actor.Member{}) + err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) assert.Equal(t, expectedError, err) } @@ -415,7 +415,7 @@ func TestPostDonorAccessRemove(t *testing.T) { logger.EXPECT(). InfoContext(r.Context(), "donor access removed", slog.String("lpa_id", "lpa-id")) - err := DonorAccess(logger, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &actor.Organisation{}, &actor.Member{}) + err := DonorAccess(logger, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) resp := w.Result() assert.Nil(t, err) @@ -449,7 +449,7 @@ func TestPostDonorAccessRemoveWhenDonorHasPaid(t *testing.T) { Get(r.Context()). Return(donor, nil) - err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &actor.Organisation{}, &actor.Member{}) + err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) resp := w.Result() assert.Error(t, err) @@ -478,7 +478,7 @@ func TestPostDonorAccessRemoveWhenDeleteLinkError(t *testing.T) { DeleteDonorAccess(mock.Anything, mock.Anything). Return(expectedError) - err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &actor.Organisation{}, &actor.Member{}) + err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "http://whatever", testRandomStringFn)(testLpaAppData, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) resp := w.Result() assert.Equal(t, expectedError, err) diff --git a/internal/page/supporter/edit_member.go b/internal/supporter/supporterpage/edit_member.go similarity index 82% rename from internal/page/supporter/edit_member.go rename to internal/supporter/supporterpage/edit_member.go index ceb9288182..bfdefb82c5 100644 --- a/internal/page/supporter/edit_member.go +++ b/internal/supporter/supporterpage/edit_member.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "log/slog" @@ -6,9 +6,9 @@ import ( "net/url" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -16,12 +16,12 @@ type editMemberData struct { App appcontext.Data Errors validation.List Form *editMemberForm - Member *actor.Member + Member *supporterdata.Member CanEditAll bool } func EditMember(logger Logger, tmpl template.Template, memberStore MemberStore) Handler { - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, member *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, member *supporterdata.Member) error { memberID := r.FormValue("id") isLoggedInMember := member.ID == memberID if !isLoggedInMember { @@ -41,9 +41,9 @@ func EditMember(logger Logger, tmpl template.Template, memberStore MemberStore) FirstNames: member.FirstNames, LastName: member.LastName, Permission: member.Permission, - PermissionOptions: actor.PermissionValues, + PermissionOptions: supporterdata.PermissionValues, Status: member.Status, - StatusOptions: actor.StatusValues, + StatusOptions: supporterdata.StatusValues, }, Member: member, CanEditAll: canEditAll, @@ -107,11 +107,11 @@ func EditMember(logger Logger, tmpl template.Template, memberStore MemberStore) type editMemberForm struct { FirstNames string LastName string - Permission actor.Permission - PermissionOptions actor.PermissionOptions + Permission supporterdata.Permission + PermissionOptions supporterdata.PermissionOptions PermissionError error - Status actor.Status - StatusOptions actor.StatusOptions + Status supporterdata.Status + StatusOptions supporterdata.StatusOptions StatusError error canEditAll bool } @@ -124,8 +124,8 @@ func readEditMemberForm(r *http.Request, canEditAll bool) *editMemberForm { } if canEditAll { - f.Permission, f.PermissionError = actor.ParsePermission(page.PostFormString(r, "permission")) - f.Status, f.StatusError = actor.ParseStatus(page.PostFormString(r, "status")) + f.Permission, f.PermissionError = supporterdata.ParsePermission(page.PostFormString(r, "permission")) + f.Status, f.StatusError = supporterdata.ParseStatus(page.PostFormString(r, "status")) } return f @@ -144,7 +144,7 @@ func (f *editMemberForm) Validate() validation.List { if f.canEditAll { errors.Options("permission", "makeThisPersonAnAdmin", []string{f.Permission.String()}, - validation.Select(actor.PermissionNone.String(), actor.PermissionAdmin.String())) + validation.Select(supporterdata.PermissionNone.String(), supporterdata.PermissionAdmin.String())) errors.Error("status", "status", f.StatusError, validation.Selected()) diff --git a/internal/page/supporter/edit_member_test.go b/internal/supporter/supporterpage/edit_member_test.go similarity index 80% rename from internal/page/supporter/edit_member_test.go rename to internal/supporter/supporterpage/edit_member_test.go index 63bf153c09..f7af2bdab8 100644 --- a/internal/page/supporter/edit_member_test.go +++ b/internal/supporter/supporterpage/edit_member_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "log/slog" @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -20,12 +20,12 @@ func TestGetEditMember(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id=an-id", nil) - member := &actor.Member{ + member := &supporterdata.Member{ ID: "an-id", FirstNames: "a", LastName: "b", - Status: actor.StatusActive, - Permission: actor.PermissionAdmin, + Status: supporterdata.StatusActive, + Permission: supporterdata.PermissionAdmin, } memberStore := newMockMemberStore(t) @@ -40,16 +40,16 @@ func TestGetEditMember(t *testing.T) { Form: &editMemberForm{ FirstNames: "a", LastName: "b", - Permission: actor.PermissionAdmin, - PermissionOptions: actor.PermissionValues, - Status: actor.StatusActive, - StatusOptions: actor.StatusValues, + Permission: supporterdata.PermissionAdmin, + PermissionOptions: supporterdata.PermissionValues, + Status: supporterdata.StatusActive, + StatusOptions: supporterdata.StatusValues, }, Member: member, }). Return(nil) - err := EditMember(nil, template.Execute, memberStore)(testAppData, w, r, &actor.Organisation{}, &actor.Member{}) + err := EditMember(nil, template.Execute, memberStore)(testAppData, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) resp := w.Result() assert.Nil(t, err) @@ -65,7 +65,7 @@ func TestGetEditMemberWhenMemberStoreError(t *testing.T) { GetByID(r.Context(), mock.Anything). Return(nil, expectedError) - err := EditMember(nil, nil, memberStore)(testAppData, w, r, &actor.Organisation{}, &actor.Member{}) + err := EditMember(nil, nil, memberStore)(testAppData, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -81,7 +81,7 @@ func TestGetEditMemberWhenTemplateError(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := EditMember(nil, template.Execute, nil)(testAppData, w, r, &actor.Organisation{}, &actor.Member{ID: "an-id"}) + err := EditMember(nil, template.Execute, nil)(testAppData, w, r, &supporterdata.Organisation{}, &supporterdata.Member{ID: "an-id"}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -90,48 +90,48 @@ func TestGetEditMemberWhenTemplateError(t *testing.T) { func TestPostEditMember(t *testing.T) { testcases := map[string]struct { - member *actor.Member + member *supporterdata.Member expectedRedirect string - expectedMember *actor.Member - userPermission actor.Permission + expectedMember *supporterdata.Member + userPermission supporterdata.Permission memberEmail string }{ "self": { - member: &actor.Member{ + member: &supporterdata.Member{ ID: "an-id", FirstNames: "a", LastName: "b", Email: "self@example.org", - Status: actor.StatusActive, - Permission: actor.PermissionAdmin, + Status: supporterdata.StatusActive, + Permission: supporterdata.PermissionAdmin, }, - userPermission: actor.PermissionAdmin, + userPermission: supporterdata.PermissionAdmin, memberEmail: "self@example.org", expectedRedirect: page.Paths.Supporter.ManageTeamMembers.Format() + "?nameUpdated=c+d&selfUpdated=1", - expectedMember: &actor.Member{ + expectedMember: &supporterdata.Member{ ID: "an-id", FirstNames: "c", LastName: "d", Email: "self@example.org", - Status: actor.StatusActive, - Permission: actor.PermissionAdmin, + Status: supporterdata.StatusActive, + Permission: supporterdata.PermissionAdmin, }, }, "non-admin": { - member: &actor.Member{ + member: &supporterdata.Member{ ID: "an-id", Email: "self@example.org", }, - userPermission: actor.PermissionNone, + userPermission: supporterdata.PermissionNone, memberEmail: "self@example.org", expectedRedirect: page.Paths.Supporter.Dashboard.Format() + "?nameUpdated=c+d&selfUpdated=1", - expectedMember: &actor.Member{ + expectedMember: &supporterdata.Member{ ID: "an-id", FirstNames: "c", LastName: "d", Email: "self@example.org", - Status: actor.StatusActive, - Permission: actor.PermissionNone, + Status: supporterdata.StatusActive, + Permission: supporterdata.PermissionNone, }, }, } @@ -159,7 +159,7 @@ func TestPostEditMember(t *testing.T) { SupporterData: &appcontext.SupporterData{ Permission: tc.userPermission, }, - }, w, r, &actor.Organisation{}, tc.member) + }, w, r, &supporterdata.Organisation{}, tc.member) resp := w.Result() assert.Nil(t, err) @@ -184,22 +184,22 @@ func TestPostEditMemberWhenOtherMember(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetByID(r.Context(), "an-id"). - Return(&actor.Member{ + Return(&supporterdata.Member{ ID: "member-id", FirstNames: "a", LastName: "b", Email: "team-member@example.org", - Status: actor.StatusActive, - Permission: actor.PermissionNone, + Status: supporterdata.StatusActive, + Permission: supporterdata.PermissionNone, }, nil) memberStore.EXPECT(). - Put(r.Context(), &actor.Member{ + Put(r.Context(), &supporterdata.Member{ ID: "member-id", FirstNames: "c", LastName: "d", Email: "team-member@example.org", - Status: actor.StatusSuspended, - Permission: actor.PermissionAdmin, + Status: supporterdata.StatusSuspended, + Permission: supporterdata.PermissionAdmin, }). Return(nil) @@ -212,9 +212,9 @@ func TestPostEditMemberWhenOtherMember(t *testing.T) { err := EditMember(logger, nil, memberStore)(appcontext.Data{ LoginSessionEmail: "self@example.org", SupporterData: &appcontext.SupporterData{ - Permission: actor.PermissionAdmin, + Permission: supporterdata.PermissionAdmin, }, - }, w, r, &actor.Organisation{}, &actor.Member{}) + }, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) resp := w.Result() assert.Nil(t, err) @@ -225,16 +225,16 @@ func TestPostEditMemberWhenOtherMember(t *testing.T) { func TestPostEditMemberNoUpdate(t *testing.T) { testcases := map[string]struct { expectedRedirect string - userPermission actor.Permission + userPermission supporterdata.Permission memberEmail string }{ "self": { - userPermission: actor.PermissionAdmin, + userPermission: supporterdata.PermissionAdmin, memberEmail: "self@example.org", expectedRedirect: page.Paths.Supporter.ManageTeamMembers.Format() + "?", }, "non-admin": { - userPermission: actor.PermissionNone, + userPermission: supporterdata.PermissionNone, memberEmail: "self@example.org", expectedRedirect: page.Paths.Supporter.Dashboard.Format() + "?", }, @@ -258,12 +258,12 @@ func TestPostEditMemberNoUpdate(t *testing.T) { SupporterData: &appcontext.SupporterData{ Permission: tc.userPermission, }, - }, w, r, &actor.Organisation{}, &actor.Member{ + }, w, r, &supporterdata.Organisation{}, &supporterdata.Member{ ID: "an-id", FirstNames: "a", LastName: "b", Email: tc.memberEmail, - Status: actor.StatusActive, + Status: supporterdata.StatusActive, Permission: tc.userPermission, }) resp := w.Result() @@ -290,20 +290,20 @@ func TestPostEditMemberNoUpdateWhenOtherMember(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetByID(r.Context(), "an-id"). - Return(&actor.Member{ + Return(&supporterdata.Member{ FirstNames: "a", LastName: "b", Email: "team-member@example.org", - Status: actor.StatusActive, - Permission: actor.PermissionAdmin, + Status: supporterdata.StatusActive, + Permission: supporterdata.PermissionAdmin, }, nil) err := EditMember(nil, nil, memberStore)(appcontext.Data{ LoginSessionEmail: "self@example.org", SupporterData: &appcontext.SupporterData{ - Permission: actor.PermissionAdmin, + Permission: supporterdata.PermissionAdmin, }, - }, w, r, &actor.Organisation{}, &actor.Member{}) + }, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) resp := w.Result() assert.Nil(t, err) @@ -324,13 +324,13 @@ func TestPostEditMemberWhenOrganisationStorePutError(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetByID(mock.Anything, mock.Anything). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) memberStore.EXPECT(). Put(mock.Anything, mock.Anything). Return(expectedError) - err := EditMember(nil, nil, memberStore)(testAppData, w, r, &actor.Organisation{}, &actor.Member{}) + err := EditMember(nil, nil, memberStore)(testAppData, w, r, &supporterdata.Organisation{}, &supporterdata.Member{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -347,7 +347,7 @@ func TestPostEditMemberWhenValidationError(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id=an-id", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - member := &actor.Member{ + member := &supporterdata.Member{ ID: "an-id", FirstNames: "a", LastName: "b", @@ -371,7 +371,7 @@ func TestPostEditMemberWhenValidationError(t *testing.T) { }). Return(nil) - err := EditMember(nil, template.Execute, memberStore)(testAppData, w, r, nil, &actor.Member{}) + err := EditMember(nil, template.Execute, memberStore)(testAppData, w, r, nil, &supporterdata.Member{}) resp := w.Result() assert.Nil(t, err) @@ -412,7 +412,7 @@ func TestReadEditMemberForm(t *testing.T) { assert.Equal(t, "b", result.LastName) if tc.isAdmin && !tc.isEditingSelf { - assert.Equal(t, actor.StatusSuspended, result.Status) + assert.Equal(t, supporterdata.StatusSuspended, result.Status) } }) } @@ -433,7 +433,7 @@ func TestEditMemberFormValidate(t *testing.T) { form: &editMemberForm{ FirstNames: "a", LastName: "b", - Status: actor.StatusSuspended, + Status: supporterdata.StatusSuspended, canEditAll: true, }, }, diff --git a/internal/page/supporter/edit_organisation_name.go b/internal/supporter/supporterpage/edit_organisation_name.go similarity index 85% rename from internal/page/supporter/edit_organisation_name.go rename to internal/supporter/supporterpage/edit_organisation_name.go index 8fa842b542..7fee71519b 100644 --- a/internal/page/supporter/edit_organisation_name.go +++ b/internal/supporter/supporterpage/edit_organisation_name.go @@ -1,13 +1,13 @@ -package supporter +package supporterpage import ( "net/http" "net/url" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -18,7 +18,7 @@ type editOrganisationNameData struct { } func EditOrganisationName(tmpl template.Template, organisationStore OrganisationStore) Handler { - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { data := &editOrganisationNameData{ App: appData, Form: &organisationNameForm{ diff --git a/internal/page/supporter/edit_organisation_name_test.go b/internal/supporter/supporterpage/edit_organisation_name_test.go similarity index 88% rename from internal/page/supporter/edit_organisation_name_test.go rename to internal/supporter/supporterpage/edit_organisation_name_test.go index 3d42e552a7..cbbc2c1976 100644 --- a/internal/page/supporter/edit_organisation_name_test.go +++ b/internal/supporter/supporterpage/edit_organisation_name_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "net/http" @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -18,7 +18,7 @@ func TestGetEditOrganisationName(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - organisation := &actor.Organisation{Name: "what"} + organisation := &supporterdata.Organisation{Name: "what"} template := newMockTemplate(t) template.EXPECT(). @@ -44,7 +44,7 @@ func TestGetEditOrganisationNameWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := EditOrganisationName(template.Execute, nil)(testAppData, w, r, &actor.Organisation{}, nil) + err := EditOrganisationName(template.Execute, nil)(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() assert.Equal(t, expectedError, err) @@ -60,10 +60,10 @@ func TestPostEditOrganisationName(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). - Put(r.Context(), &actor.Organisation{PK: "ORG", Name: "My organisation"}). + Put(r.Context(), &supporterdata.Organisation{PK: "ORG", Name: "My organisation"}). Return(nil) - err := EditOrganisationName(nil, organisationStore)(testAppData, w, r, &actor.Organisation{PK: "ORG"}, nil) + err := EditOrganisationName(nil, organisationStore)(testAppData, w, r, &supporterdata.Organisation{PK: "ORG"}, nil) resp := w.Result() assert.Nil(t, err) @@ -89,7 +89,7 @@ func TestPostEditOrganisationNameWhenValidationError(t *testing.T) { })). Return(nil) - err := EditOrganisationName(template.Execute, nil)(testAppData, w, r, &actor.Organisation{}, nil) + err := EditOrganisationName(template.Execute, nil)(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() assert.Nil(t, err) @@ -111,7 +111,7 @@ func TestPostEditOrganisationNameWhenOrganisationStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EditOrganisationName(nil, organisationStore)(testAppData, w, r, &actor.Organisation{}, nil) + err := EditOrganisationName(nil, organisationStore)(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() assert.Equal(t, expectedError, err) diff --git a/internal/page/supporter/enter_organisation_name.go b/internal/supporter/supporterpage/enter_organisation_name.go similarity index 99% rename from internal/page/supporter/enter_organisation_name.go rename to internal/supporter/supporterpage/enter_organisation_name.go index 159fdf0d8e..9d35515738 100644 --- a/internal/page/supporter/enter_organisation_name.go +++ b/internal/supporter/supporterpage/enter_organisation_name.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "log/slog" diff --git a/internal/page/supporter/enter_organisation_name_test.go b/internal/supporter/supporterpage/enter_organisation_name_test.go similarity index 94% rename from internal/page/supporter/enter_organisation_name_test.go rename to internal/supporter/supporterpage/enter_organisation_name_test.go index 57aa2ad90b..a6cabbd153 100644 --- a/internal/page/supporter/enter_organisation_name_test.go +++ b/internal/supporter/supporterpage/enter_organisation_name_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "log/slog" @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -58,7 +58,7 @@ func TestPostEnterOrganisationName(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - member := &actor.Member{ID: "a"} + member := &supporterdata.Member{ID: "a"} memberStore := newMockMemberStore(t) memberStore.EXPECT(). @@ -68,7 +68,7 @@ func TestPostEnterOrganisationName(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Create(r.Context(), member, "My organisation"). - Return(&actor.Organisation{ID: "org-id", Name: "My organisation"}, nil) + Return(&supporterdata.Organisation{ID: "org-id", Name: "My organisation"}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -110,12 +110,12 @@ func TestPostEnterOrganisationNameWhenSessionStoreSaveError(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(r.Context()). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Create(r.Context(), mock.Anything, mock.Anything). - Return(&actor.Organisation{}, nil) + Return(&supporterdata.Organisation{}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -148,12 +148,12 @@ func TestPostEnterOrganisationNameWhenSessionStoreGetError(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(r.Context()). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Create(r.Context(), mock.Anything, mock.Anything). - Return(&actor.Organisation{}, nil) + Return(&supporterdata.Organisation{}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -232,7 +232,7 @@ func TestPostEnterOrganisationNameWhenOrganisationStoreErrors(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(r.Context()). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). diff --git a/internal/page/supporter/enter_reference_number.go b/internal/supporter/supporterpage/enter_reference_number.go similarity index 99% rename from internal/page/supporter/enter_reference_number.go rename to internal/supporter/supporterpage/enter_reference_number.go index 80c9abb647..9801a6434a 100644 --- a/internal/page/supporter/enter_reference_number.go +++ b/internal/supporter/supporterpage/enter_reference_number.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "log/slog" diff --git a/internal/page/supporter/enter_reference_number_test.go b/internal/supporter/supporterpage/enter_reference_number_test.go similarity index 95% rename from internal/page/supporter/enter_reference_number_test.go rename to internal/supporter/supporterpage/enter_reference_number_test.go index b56143510b..d706908e15 100644 --- a/internal/page/supporter/enter_reference_number_test.go +++ b/internal/supporter/supporterpage/enter_reference_number_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "log/slog" @@ -9,9 +9,9 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -66,7 +66,7 @@ func TestPostEnterReferenceNumber(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - invite := &actor.MemberInvite{ + invite := &supporterdata.MemberInvite{ ReferenceNumber: "abcd12345678", OrganisationID: "org-id", OrganisationName: "org name", @@ -113,7 +113,7 @@ func TestPostEnterReferenceNumberWhenIncorrectReferenceNumber(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). InvitedMember(r.Context()). - Return(&actor.MemberInvite{ReferenceNumber: "notmatch123", OrganisationID: "org-id"}, nil) + Return(&supporterdata.MemberInvite{ReferenceNumber: "notmatch123", OrganisationID: "org-id"}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -145,7 +145,7 @@ func TestPostEnterReferenceNumberWhenInviteExpired(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). InvitedMember(r.Context()). - Return(&actor.MemberInvite{ + Return(&supporterdata.MemberInvite{ ReferenceNumber: "match1234789", OrganisationID: "org-id", CreatedAt: time.Now().Add(-49 * time.Hour), @@ -169,7 +169,7 @@ func TestPostEnterReferenceNumberWhenMemberStoreInvitedMemberError(t *testing.T) memberStore := newMockMemberStore(t) memberStore.EXPECT(). InvitedMember(mock.Anything). - Return(&actor.MemberInvite{}, expectedError) + Return(&supporterdata.MemberInvite{}, expectedError) err := EnterReferenceNumber(nil, nil, memberStore, nil)(testAppData, w, r) resp := w.Result() @@ -188,7 +188,7 @@ func TestPostEnterReferenceNumberWhenMemberStoreCreateError(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). InvitedMember(mock.Anything). - Return(&actor.MemberInvite{ + Return(&supporterdata.MemberInvite{ ReferenceNumber: "abcd12345678", OrganisationID: "org-id", CreatedAt: time.Now(), @@ -215,7 +215,7 @@ func TestPostEnterReferenceNumberWhenSessionGetError(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). InvitedMember(mock.Anything). - Return(&actor.MemberInvite{ + Return(&supporterdata.MemberInvite{ ReferenceNumber: "abcd12345678", OrganisationID: "org-id", CreatedAt: time.Now(), @@ -248,7 +248,7 @@ func TestPostEnterReferenceNumberWhenSessionSaveError(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). InvitedMember(mock.Anything). - Return(&actor.MemberInvite{ + Return(&supporterdata.MemberInvite{ ReferenceNumber: "abcd12345678", OrganisationID: "org-id", CreatedAt: time.Now(), diff --git a/internal/page/supporter/enter_your_name.go b/internal/supporter/supporterpage/enter_your_name.go similarity index 98% rename from internal/page/supporter/enter_your_name.go rename to internal/supporter/supporterpage/enter_your_name.go index 70d4e391bc..5ae19703ec 100644 --- a/internal/page/supporter/enter_your_name.go +++ b/internal/supporter/supporterpage/enter_your_name.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "net/http" diff --git a/internal/page/supporter/enter_your_name_test.go b/internal/supporter/supporterpage/enter_your_name_test.go similarity index 96% rename from internal/page/supporter/enter_your_name_test.go rename to internal/supporter/supporterpage/enter_your_name_test.go index 56db7ed450..5519b6042e 100644 --- a/internal/page/supporter/enter_your_name_test.go +++ b/internal/supporter/supporterpage/enter_your_name_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "net/http" @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -59,7 +59,7 @@ func TestPostEnterYourName(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). Create(r.Context(), "John", "Smith"). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) err := EnterYourName(nil, memberStore)(testAppData, w, r) resp := w.Result() diff --git a/internal/page/supporter/guidance.go b/internal/supporter/supporterpage/guidance.go similarity index 71% rename from internal/page/supporter/guidance.go rename to internal/supporter/supporterpage/guidance.go index d7709cb5d2..3a354c8e8f 100644 --- a/internal/page/supporter/guidance.go +++ b/internal/supporter/supporterpage/guidance.go @@ -1,12 +1,12 @@ -package supporter +package supporterpage import ( "net/http" "net/url" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -14,11 +14,11 @@ type guidanceData struct { App appcontext.Data Query url.Values Errors validation.List - Organisation *actor.Organisation + Organisation *supporterdata.Organisation } func Guidance(tmpl template.Template) Handler { - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { return tmpl(w, &guidanceData{ App: appData, Query: r.URL.Query(), diff --git a/internal/page/supporter/guidance_test.go b/internal/supporter/supporterpage/guidance_test.go similarity index 97% rename from internal/page/supporter/guidance_test.go rename to internal/supporter/supporterpage/guidance_test.go index 48209f4dbb..fd67e8731f 100644 --- a/internal/page/supporter/guidance_test.go +++ b/internal/supporter/supporterpage/guidance_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "net/http" diff --git a/internal/page/supporter/invite_member.go b/internal/supporter/supporterpage/invite_member.go similarity index 82% rename from internal/page/supporter/invite_member.go rename to internal/supporter/supporterpage/invite_member.go index b7bf350464..438e3b338e 100644 --- a/internal/page/supporter/invite_member.go +++ b/internal/supporter/supporterpage/invite_member.go @@ -1,14 +1,14 @@ -package supporter +package supporterpage import ( "net/http" "net/url" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -16,15 +16,15 @@ type inviteMemberData struct { App appcontext.Data Errors validation.List Form *inviteMemberForm - Options actor.PermissionOptions + Options supporterdata.PermissionOptions } func InviteMember(tmpl template.Template, memberStore MemberStore, notifyClient NotifyClient, randomString func(int) string, appPublicURL string) Handler { - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { data := &inviteMemberData{ App: appData, Form: &inviteMemberForm{}, - Options: actor.PermissionValues, + Options: supporterdata.PermissionValues, } if r.Method == http.MethodPost { @@ -66,7 +66,7 @@ type inviteMemberForm struct { FirstNames string LastName string Email string - Permission actor.Permission + Permission supporterdata.Permission } func readInviteMemberForm(r *http.Request) *inviteMemberForm { @@ -76,7 +76,7 @@ func readInviteMemberForm(r *http.Request) *inviteMemberForm { LastName: page.PostFormString(r, "last-name"), } - form.Permission, _ = actor.ParsePermission(page.PostFormString(r, "permission")) + form.Permission, _ = supporterdata.ParsePermission(page.PostFormString(r, "permission")) return form } @@ -96,7 +96,7 @@ func (f *inviteMemberForm) Validate() validation.List { validation.Empty(), validation.Email()) - errors.Options("permission", "makeThisPersonAnAdmin", []string{f.Permission.String()}, validation.Select(actor.PermissionNone.String(), actor.PermissionAdmin.String())) + errors.Options("permission", "makeThisPersonAnAdmin", []string{f.Permission.String()}, validation.Select(supporterdata.PermissionNone.String(), supporterdata.PermissionAdmin.String())) return errors } diff --git a/internal/page/supporter/invite_member_test.go b/internal/supporter/supporterpage/invite_member_test.go similarity index 89% rename from internal/page/supporter/invite_member_test.go rename to internal/supporter/supporterpage/invite_member_test.go index 2d8d919361..8ff80ee485 100644 --- a/internal/page/supporter/invite_member_test.go +++ b/internal/supporter/supporterpage/invite_member_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "net/http" @@ -7,9 +7,9 @@ import ( "strings" "testing" - actor "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -24,7 +24,7 @@ func TestGetInviteMember(t *testing.T) { Execute(w, &inviteMemberData{ App: testAppData, Form: &inviteMemberForm{}, - Options: actor.PermissionValues, + Options: supporterdata.PermissionValues, }). Return(nil) @@ -63,11 +63,11 @@ func TestPostInviteMember(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - organisation := &actor.Organisation{Name: "My organisation"} + organisation := &supporterdata.Organisation{Name: "My organisation"} memberStore := newMockMemberStore(t) memberStore.EXPECT(). - CreateMemberInvite(r.Context(), organisation, "a", "b", "email@example.com", "abcde", actor.PermissionAdmin). + CreateMemberInvite(r.Context(), organisation, "a", "b", "email@example.com", "abcde", supporterdata.PermissionAdmin). Return(nil) notifyClient := newMockNotifyClient(t) @@ -109,9 +109,9 @@ func TestPostInviteMemberWhenValidationError(t *testing.T) { FirstNames: "a", LastName: "b", Email: "what", - Permission: actor.PermissionAdmin, + Permission: supporterdata.PermissionAdmin, }, - Options: actor.PermissionValues, + Options: supporterdata.PermissionValues, }). Return(nil) @@ -139,7 +139,7 @@ func TestPostInviteMemberWhenCreateMemberInviteErrors(t *testing.T) { CreateMemberInvite(r.Context(), mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything). Return(expectedError) - err := InviteMember(nil, memberStore, nil, func(int) string { return "abcde" }, "http://base")(testAppData, w, r, &actor.Organisation{}, nil) + err := InviteMember(nil, memberStore, nil, func(int) string { return "abcde" }, "http://base")(testAppData, w, r, &supporterdata.Organisation{}, nil) assert.Equal(t, expectedError, err) } @@ -165,7 +165,7 @@ func TestPostInviteMemberWhenNotifySendErrors(t *testing.T) { SendEmail(r.Context(), mock.Anything, mock.Anything). Return(expectedError) - err := InviteMember(nil, memberStore, notifyClient, func(int) string { return "abcde" }, "http://base")(testAppData, w, r, &actor.Organisation{}, nil) + err := InviteMember(nil, memberStore, notifyClient, func(int) string { return "abcde" }, "http://base")(testAppData, w, r, &supporterdata.Organisation{}, nil) assert.Equal(t, expectedError, err) } @@ -185,7 +185,7 @@ func TestReadInviteMemberForm(t *testing.T) { assert.Equal(t, "email@example.com", result.Email) assert.Equal(t, "a", result.FirstNames) assert.Equal(t, "b", result.LastName) - assert.Equal(t, actor.PermissionAdmin, result.Permission) + assert.Equal(t, supporterdata.PermissionAdmin, result.Permission) } func TestInviteMemberFormValidate(t *testing.T) { @@ -198,7 +198,7 @@ func TestInviteMemberFormValidate(t *testing.T) { Email: "email@example.com", FirstNames: "a", LastName: "b", - Permission: actor.PermissionNone, + Permission: supporterdata.PermissionNone, }, }, "missing": { @@ -213,7 +213,7 @@ func TestInviteMemberFormValidate(t *testing.T) { Email: "what", FirstNames: "a", LastName: "b", - Permission: actor.PermissionNone, + Permission: supporterdata.PermissionNone, }, errors: validation.With("email", validation.EmailError{Label: "email"}), }, @@ -222,7 +222,7 @@ func TestInviteMemberFormValidate(t *testing.T) { Email: "email@example.com", FirstNames: strings.Repeat("x", 54), LastName: strings.Repeat("x", 62), - Permission: actor.PermissionNone, + Permission: supporterdata.PermissionNone, }, errors: validation. With("first-names", validation.StringTooLongError{Label: "firstNames", Length: 53}). @@ -233,7 +233,7 @@ func TestInviteMemberFormValidate(t *testing.T) { Email: "email@example.com", FirstNames: "a", LastName: "b", - Permission: actor.Permission(99), + Permission: supporterdata.Permission(99), }, errors: validation. With("permission", validation.SelectError{Label: "makeThisPersonAnAdmin"}), diff --git a/internal/page/supporter/login_callback.go b/internal/supporter/supporterpage/login_callback.go similarity index 99% rename from internal/page/supporter/login_callback.go rename to internal/supporter/supporterpage/login_callback.go index 0ba71b6240..a87e5435cc 100644 --- a/internal/page/supporter/login_callback.go +++ b/internal/supporter/supporterpage/login_callback.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "context" diff --git a/internal/page/supporter/login_callback_test.go b/internal/supporter/supporterpage/login_callback_test.go similarity index 94% rename from internal/page/supporter/login_callback_test.go rename to internal/supporter/supporterpage/login_callback_test.go index 8f8c99631e..79371f36a4 100644 --- a/internal/page/supporter/login_callback_test.go +++ b/internal/supporter/supporterpage/login_callback_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "errors" @@ -8,12 +8,12 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -25,14 +25,14 @@ var ( func TestLoginCallback(t *testing.T) { testcases := map[string]struct { - invites []*actor.MemberInvite + invites []*supporterdata.MemberInvite redirect page.Path }{ "no invite": { redirect: page.Paths.Supporter.EnterYourName, }, "has invite": { - invites: []*actor.MemberInvite{{}}, + invites: []*supporterdata.MemberInvite{{}}, redirect: page.Paths.Supporter.EnterReferenceNumber, }, } @@ -166,7 +166,7 @@ func TestLoginCallbackWhenInvitedMembersByEmailErrors(t *testing.T) { Return(nil, dynamo.NotFoundError{}) memberStore.EXPECT(). InvitedMembersByEmail(mock.Anything). - Return([]*actor.MemberInvite{{}}, expectedError) + Return([]*supporterdata.MemberInvite{{}}, expectedError) logger := newMockLogger(t) logger.EXPECT(). @@ -213,7 +213,7 @@ func TestLoginCallbackHasMember(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: loginSession.SessionID(), Email: loginSession.Email})). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). @@ -260,12 +260,12 @@ func TestLoginCallbackHasMemberWhenSessionErrors(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(mock.Anything). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(mock.Anything). - Return(&actor.Organisation{ID: "org-id", Name: "org name"}, dynamo.NotFoundError{}) + Return(&supporterdata.Organisation{ID: "org-id", Name: "org name"}, dynamo.NotFoundError{}) logger := newMockLogger(t) logger.EXPECT(). @@ -311,7 +311,7 @@ func TestLoginCallbackHasMemberWhenOrganisationGetErrors(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(ctx). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). @@ -378,16 +378,16 @@ func TestLoginCallbackHasOrganisation(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: loginSession.SessionID(), Email: loginSession.Email})). - Return(&actor.Member{Email: tc.existingMemberEmail}, nil) + Return(&supporterdata.Member{Email: tc.existingMemberEmail}, nil) memberStore.EXPECT(). - Put(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: loginSession.SessionID(), Email: loginSession.Email, OrganisationID: "org-id"}), &actor.Member{Email: tc.loginSessionEmail, LastLoggedInAt: testNow}). + Put(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: loginSession.SessionID(), Email: loginSession.Email, OrganisationID: "org-id"}), &supporterdata.Member{Email: tc.loginSessionEmail, LastLoggedInAt: testNow}). Return(nil) organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: loginSession.SessionID(), Email: loginSession.Email})). - Return(&actor.Organisation{ID: "org-id", Name: "org name"}, nil) + Return(&supporterdata.Organisation{ID: "org-id", Name: "org name"}, nil) logger := newMockLogger(t) logger.EXPECT(). @@ -431,7 +431,7 @@ func TestLoginCallbackHasOrganisationWhenMemberPutErrors(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(mock.Anything). - Return(&actor.Member{Email: "email@example.com"}, nil) + Return(&supporterdata.Member{Email: "email@example.com"}, nil) memberStore.EXPECT(). Put(mock.Anything, mock.Anything). Return(expectedError) @@ -439,7 +439,7 @@ func TestLoginCallbackHasOrganisationWhenMemberPutErrors(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(mock.Anything). - Return(&actor.Organisation{ID: "org-id", Name: "org name"}, nil) + Return(&supporterdata.Organisation{ID: "org-id", Name: "org name"}, nil) logger := newMockLogger(t) logger.EXPECT(). @@ -477,12 +477,12 @@ func TestLoginCallbackHasOrganisationWhenSessionErrors(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(mock.Anything). - Return(&actor.Member{Email: "email@example.com"}, nil) + Return(&supporterdata.Member{Email: "email@example.com"}, nil) organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(mock.Anything). - Return(&actor.Organisation{ID: "org-id", Name: "org name"}, nil) + Return(&supporterdata.Organisation{ID: "org-id", Name: "org name"}, nil) logger := newMockLogger(t) logger.EXPECT(). @@ -572,12 +572,12 @@ func TestLoginCallbackWhenSessionError(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). GetAny(mock.Anything). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(mock.Anything). - Return(&actor.Organisation{}, nil) + Return(&supporterdata.Organisation{}, nil) logger := newMockLogger(t) logger.EXPECT(). diff --git a/internal/page/supporter/manage_team_members.go b/internal/supporter/supporterpage/manage_team_members.go similarity index 87% rename from internal/page/supporter/manage_team_members.go rename to internal/supporter/supporterpage/manage_team_members.go index de446953a1..9dd1b4093c 100644 --- a/internal/page/supporter/manage_team_members.go +++ b/internal/supporter/supporterpage/manage_team_members.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "errors" @@ -6,24 +6,24 @@ import ( "net/url" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type manageTeamMembersData struct { App appcontext.Data Errors validation.List - Organisation *actor.Organisation - InvitedMembers []*actor.MemberInvite - Members []*actor.Member + Organisation *supporterdata.Organisation + InvitedMembers []*supporterdata.MemberInvite + Members []*supporterdata.Member Form *inviteMemberForm } func ManageTeamMembers(tmpl template.Template, memberStore MemberStore, randomString func(int) string, notifyClient NotifyClient, appPublicURL string) Handler { - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { data := &manageTeamMembersData{ App: appData, Organisation: organisation, diff --git a/internal/page/supporter/manage_team_members_test.go b/internal/supporter/supporterpage/manage_team_members_test.go similarity index 82% rename from internal/page/supporter/manage_team_members_test.go rename to internal/supporter/supporterpage/manage_team_members_test.go index ea6876893e..86a9f9e5de 100644 --- a/internal/page/supporter/manage_team_members_test.go +++ b/internal/supporter/supporterpage/manage_team_members_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "net/http" @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -21,22 +21,22 @@ func TestGetManageTeamMembers(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). InvitedMembers(r.Context()). - Return([]*actor.MemberInvite{{FirstNames: "a"}, {FirstNames: "b"}}, nil) + Return([]*supporterdata.MemberInvite{{FirstNames: "a"}, {FirstNames: "b"}}, nil) memberStore.EXPECT(). GetAll(r.Context()). - Return([]*actor.Member{{FirstNames: "c"}, {FirstNames: "d"}}, nil) + Return([]*supporterdata.Member{{FirstNames: "c"}, {FirstNames: "d"}}, nil) template := newMockTemplate(t) template.EXPECT(). Execute(w, &manageTeamMembersData{ App: testAppData, - Organisation: &actor.Organisation{ID: "org-id"}, - InvitedMembers: []*actor.MemberInvite{{FirstNames: "a"}, {FirstNames: "b"}}, - Members: []*actor.Member{{FirstNames: "c"}, {FirstNames: "d"}}, + Organisation: &supporterdata.Organisation{ID: "org-id"}, + InvitedMembers: []*supporterdata.MemberInvite{{FirstNames: "a"}, {FirstNames: "b"}}, + Members: []*supporterdata.Member{{FirstNames: "c"}, {FirstNames: "d"}}, }). Return(nil) - err := ManageTeamMembers(template.Execute, memberStore, nil, nil, "")(testAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) + err := ManageTeamMembers(template.Execute, memberStore, nil, nil, "")(testAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, nil) resp := w.Result() @@ -65,15 +65,15 @@ func TestGetManageTeamMembersWhenMemberStoreErrors(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). InvitedMembers(mock.Anything). - Return([]*actor.MemberInvite{}, tc.invitedMembersError) + Return([]*supporterdata.MemberInvite{}, tc.invitedMembersError) if tc.membersError != nil { memberStore.EXPECT(). GetAll(mock.Anything). - Return([]*actor.Member{}, tc.membersError) + Return([]*supporterdata.Member{}, tc.membersError) } - err := ManageTeamMembers(nil, memberStore, nil, nil, "")(testAppData, w, r, &actor.Organisation{}, nil) + err := ManageTeamMembers(nil, memberStore, nil, nil, "")(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() @@ -90,17 +90,17 @@ func TestGetManageTeamMembersWhenTemplateError(t *testing.T) { memberStore := newMockMemberStore(t) memberStore.EXPECT(). InvitedMembers(mock.Anything). - Return([]*actor.MemberInvite{}, nil) + Return([]*supporterdata.MemberInvite{}, nil) memberStore.EXPECT(). GetAll(mock.Anything). - Return([]*actor.Member{{FirstNames: "c"}, {FirstNames: "d"}}, nil) + Return([]*supporterdata.Member{{FirstNames: "c"}, {FirstNames: "d"}}, nil) template := newMockTemplate(t) template.EXPECT(). Execute(w, mock.Anything). Return(expectedError) - err := ManageTeamMembers(template.Execute, memberStore, nil, nil, "")(testAppData, w, r, &actor.Organisation{}, nil) + err := ManageTeamMembers(template.Execute, memberStore, nil, nil, "")(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() @@ -120,14 +120,14 @@ func TestPostManageTeamMembers(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - organisation := &actor.Organisation{Name: "My organisation", ID: "org-id"} + organisation := &supporterdata.Organisation{Name: "My organisation", ID: "org-id"} memberStore := newMockMemberStore(t) memberStore.EXPECT(). DeleteMemberInvite(r.Context(), organisation.ID, "email@example.com"). Return(nil) memberStore.EXPECT(). - CreateMemberInvite(r.Context(), organisation, "a", "b", "email@example.com", "abcde", actor.PermissionAdmin). + CreateMemberInvite(r.Context(), organisation, "a", "b", "email@example.com", "abcde", supporterdata.PermissionAdmin). Return(nil) notifyClient := newMockNotifyClient(t) @@ -161,7 +161,7 @@ func TestPostManageTeamMembersWhenValidationErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := ManageTeamMembers(nil, nil, func(int) string { return "abcde" }, nil, "http://base")(testAppData, w, r, &actor.Organisation{ID: "org-id", Name: "My organisation"}, nil) + err := ManageTeamMembers(nil, nil, func(int) string { return "abcde" }, nil, "http://base")(testAppData, w, r, &supporterdata.Organisation{ID: "org-id", Name: "My organisation"}, nil) resp := w.Result() @@ -206,7 +206,7 @@ func TestPostManageTeamMembersWhenMemberStoreErrors(t *testing.T) { Return(tc.createMemberInvite) } - err := ManageTeamMembers(nil, memberStore, func(int) string { return "abcde" }, nil, "")(testAppData, w, r, &actor.Organisation{}, nil) + err := ManageTeamMembers(nil, memberStore, func(int) string { return "abcde" }, nil, "")(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() @@ -241,7 +241,7 @@ func TestPostManageTeamMembersWhenNotifyClientError(t *testing.T) { SendEmail(mock.Anything, mock.Anything, mock.Anything). Return(expectedError) - err := ManageTeamMembers(nil, memberStore, func(int) string { return "abcde" }, notifyClient, "")(testAppData, w, r, &actor.Organisation{}, nil) + err := ManageTeamMembers(nil, memberStore, func(int) string { return "abcde" }, notifyClient, "")(testAppData, w, r, &supporterdata.Organisation{}, nil) resp := w.Result() diff --git a/internal/page/supporter/mock_CertificateProviderStore_test.go b/internal/supporter/supporterpage/mock_CertificateProviderStore_test.go similarity index 99% rename from internal/page/supporter/mock_CertificateProviderStore_test.go rename to internal/supporter/supporterpage/mock_CertificateProviderStore_test.go index ae1471c991..990ebb9a60 100644 --- a/internal/page/supporter/mock_CertificateProviderStore_test.go +++ b/internal/supporter/supporterpage/mock_CertificateProviderStore_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" diff --git a/internal/page/supporter/mock_DonorStore_test.go b/internal/supporter/supporterpage/mock_DonorStore_test.go similarity index 99% rename from internal/page/supporter/mock_DonorStore_test.go rename to internal/supporter/supporterpage/mock_DonorStore_test.go index 89fdbcbaab..e0d5bb5fc3 100644 --- a/internal/page/supporter/mock_DonorStore_test.go +++ b/internal/supporter/supporterpage/mock_DonorStore_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" diff --git a/internal/page/supporter/mock_ErrorHandler_test.go b/internal/supporter/supporterpage/mock_ErrorHandler_test.go similarity index 98% rename from internal/page/supporter/mock_ErrorHandler_test.go rename to internal/supporter/supporterpage/mock_ErrorHandler_test.go index 47405ac45b..37d486d64f 100644 --- a/internal/page/supporter/mock_ErrorHandler_test.go +++ b/internal/supporter/supporterpage/mock_ErrorHandler_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( http "net/http" diff --git a/internal/page/supporter/mock_Handler_test.go b/internal/supporter/supporterpage/mock_Handler_test.go similarity index 74% rename from internal/page/supporter/mock_Handler_test.go rename to internal/supporter/supporterpage/mock_Handler_test.go index 85bb765c81..cda73a1e50 100644 --- a/internal/page/supporter/mock_Handler_test.go +++ b/internal/supporter/supporterpage/mock_Handler_test.go @@ -1,14 +1,15 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( - actor "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" - appcontext "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" - http "net/http" + appcontext "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" + mock "github.com/stretchr/testify/mock" + + supporterdata "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" ) // mockHandler is an autogenerated mock type for the Handler type @@ -25,7 +26,7 @@ func (_m *mockHandler) EXPECT() *mockHandler_Expecter { } // Execute provides a mock function with given fields: data, w, r, organisation, member -func (_m *mockHandler) Execute(data appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, member *actor.Member) error { +func (_m *mockHandler) Execute(data appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, member *supporterdata.Member) error { ret := _m.Called(data, w, r, organisation, member) if len(ret) == 0 { @@ -33,7 +34,7 @@ func (_m *mockHandler) Execute(data appcontext.Data, w http.ResponseWriter, r *h } var r0 error - if rf, ok := ret.Get(0).(func(appcontext.Data, http.ResponseWriter, *http.Request, *actor.Organisation, *actor.Member) error); ok { + if rf, ok := ret.Get(0).(func(appcontext.Data, http.ResponseWriter, *http.Request, *supporterdata.Organisation, *supporterdata.Member) error); ok { r0 = rf(data, w, r, organisation, member) } else { r0 = ret.Error(0) @@ -51,15 +52,15 @@ type mockHandler_Execute_Call struct { // - data appcontext.Data // - w http.ResponseWriter // - r *http.Request -// - organisation *actor.Organisation -// - member *actor.Member +// - organisation *supporterdata.Organisation +// - member *supporterdata.Member func (_e *mockHandler_Expecter) Execute(data interface{}, w interface{}, r interface{}, organisation interface{}, member interface{}) *mockHandler_Execute_Call { return &mockHandler_Execute_Call{Call: _e.mock.On("Execute", data, w, r, organisation, member)} } -func (_c *mockHandler_Execute_Call) Run(run func(data appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, member *actor.Member)) *mockHandler_Execute_Call { +func (_c *mockHandler_Execute_Call) Run(run func(data appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, member *supporterdata.Member)) *mockHandler_Execute_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(appcontext.Data), args[1].(http.ResponseWriter), args[2].(*http.Request), args[3].(*actor.Organisation), args[4].(*actor.Member)) + run(args[0].(appcontext.Data), args[1].(http.ResponseWriter), args[2].(*http.Request), args[3].(*supporterdata.Organisation), args[4].(*supporterdata.Member)) }) return _c } @@ -69,7 +70,7 @@ func (_c *mockHandler_Execute_Call) Return(_a0 error) *mockHandler_Execute_Call return _c } -func (_c *mockHandler_Execute_Call) RunAndReturn(run func(appcontext.Data, http.ResponseWriter, *http.Request, *actor.Organisation, *actor.Member) error) *mockHandler_Execute_Call { +func (_c *mockHandler_Execute_Call) RunAndReturn(run func(appcontext.Data, http.ResponseWriter, *http.Request, *supporterdata.Organisation, *supporterdata.Member) error) *mockHandler_Execute_Call { _c.Call.Return(run) return _c } diff --git a/internal/page/supporter/mock_Localizer_test.go b/internal/supporter/supporterpage/mock_Localizer_test.go similarity index 99% rename from internal/page/supporter/mock_Localizer_test.go rename to internal/supporter/supporterpage/mock_Localizer_test.go index 3d66c6c6ed..36bbe4fddb 100644 --- a/internal/page/supporter/mock_Localizer_test.go +++ b/internal/supporter/supporterpage/mock_Localizer_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( date "github.com/ministryofjustice/opg-modernising-lpa/internal/date" diff --git a/internal/page/supporter/mock_Logger_test.go b/internal/supporter/supporterpage/mock_Logger_test.go similarity index 99% rename from internal/page/supporter/mock_Logger_test.go rename to internal/supporter/supporterpage/mock_Logger_test.go index b3d158d762..7140aed53b 100644 --- a/internal/page/supporter/mock_Logger_test.go +++ b/internal/supporter/supporterpage/mock_Logger_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" diff --git a/internal/page/supporter/mock_LoginCallbackOneLoginClient_test.go b/internal/supporter/supporterpage/mock_LoginCallbackOneLoginClient_test.go similarity index 99% rename from internal/page/supporter/mock_LoginCallbackOneLoginClient_test.go rename to internal/supporter/supporterpage/mock_LoginCallbackOneLoginClient_test.go index 29ff6acc26..3c33325b51 100644 --- a/internal/page/supporter/mock_LoginCallbackOneLoginClient_test.go +++ b/internal/supporter/supporterpage/mock_LoginCallbackOneLoginClient_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" diff --git a/internal/page/supporter/mock_LpaStoreResolvingService_test.go b/internal/supporter/supporterpage/mock_LpaStoreResolvingService_test.go similarity index 99% rename from internal/page/supporter/mock_LpaStoreResolvingService_test.go rename to internal/supporter/supporterpage/mock_LpaStoreResolvingService_test.go index 0e377a687c..df1570025a 100644 --- a/internal/page/supporter/mock_LpaStoreResolvingService_test.go +++ b/internal/supporter/supporterpage/mock_LpaStoreResolvingService_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" diff --git a/internal/page/supporter/mock_MemberStore_test.go b/internal/supporter/supporterpage/mock_MemberStore_test.go similarity index 74% rename from internal/page/supporter/mock_MemberStore_test.go rename to internal/supporter/supporterpage/mock_MemberStore_test.go index cd96e90e6c..5b16c4b957 100644 --- a/internal/page/supporter/mock_MemberStore_test.go +++ b/internal/supporter/supporterpage/mock_MemberStore_test.go @@ -1,12 +1,11 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" - actor "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" - + supporterdata "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" mock "github.com/stretchr/testify/mock" ) @@ -24,23 +23,23 @@ func (_m *mockMemberStore) EXPECT() *mockMemberStore_Expecter { } // Create provides a mock function with given fields: ctx, firstNames, lastName -func (_m *mockMemberStore) Create(ctx context.Context, firstNames string, lastName string) (*actor.Member, error) { +func (_m *mockMemberStore) Create(ctx context.Context, firstNames string, lastName string) (*supporterdata.Member, error) { ret := _m.Called(ctx, firstNames, lastName) if len(ret) == 0 { panic("no return value specified for Create") } - var r0 *actor.Member + var r0 *supporterdata.Member var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*actor.Member, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*supporterdata.Member, error)); ok { return rf(ctx, firstNames, lastName) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *actor.Member); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) *supporterdata.Member); ok { r0 = rf(ctx, firstNames, lastName) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*actor.Member) + r0 = ret.Get(0).(*supporterdata.Member) } } @@ -73,18 +72,18 @@ func (_c *mockMemberStore_Create_Call) Run(run func(ctx context.Context, firstNa return _c } -func (_c *mockMemberStore_Create_Call) Return(_a0 *actor.Member, _a1 error) *mockMemberStore_Create_Call { +func (_c *mockMemberStore_Create_Call) Return(_a0 *supporterdata.Member, _a1 error) *mockMemberStore_Create_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockMemberStore_Create_Call) RunAndReturn(run func(context.Context, string, string) (*actor.Member, error)) *mockMemberStore_Create_Call { +func (_c *mockMemberStore_Create_Call) RunAndReturn(run func(context.Context, string, string) (*supporterdata.Member, error)) *mockMemberStore_Create_Call { _c.Call.Return(run) return _c } // CreateFromInvite provides a mock function with given fields: ctx, invite -func (_m *mockMemberStore) CreateFromInvite(ctx context.Context, invite *actor.MemberInvite) error { +func (_m *mockMemberStore) CreateFromInvite(ctx context.Context, invite *supporterdata.MemberInvite) error { ret := _m.Called(ctx, invite) if len(ret) == 0 { @@ -92,7 +91,7 @@ func (_m *mockMemberStore) CreateFromInvite(ctx context.Context, invite *actor.M } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *actor.MemberInvite) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *supporterdata.MemberInvite) error); ok { r0 = rf(ctx, invite) } else { r0 = ret.Error(0) @@ -108,14 +107,14 @@ type mockMemberStore_CreateFromInvite_Call struct { // CreateFromInvite is a helper method to define mock.On call // - ctx context.Context -// - invite *actor.MemberInvite +// - invite *supporterdata.MemberInvite func (_e *mockMemberStore_Expecter) CreateFromInvite(ctx interface{}, invite interface{}) *mockMemberStore_CreateFromInvite_Call { return &mockMemberStore_CreateFromInvite_Call{Call: _e.mock.On("CreateFromInvite", ctx, invite)} } -func (_c *mockMemberStore_CreateFromInvite_Call) Run(run func(ctx context.Context, invite *actor.MemberInvite)) *mockMemberStore_CreateFromInvite_Call { +func (_c *mockMemberStore_CreateFromInvite_Call) Run(run func(ctx context.Context, invite *supporterdata.MemberInvite)) *mockMemberStore_CreateFromInvite_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*actor.MemberInvite)) + run(args[0].(context.Context), args[1].(*supporterdata.MemberInvite)) }) return _c } @@ -125,13 +124,13 @@ func (_c *mockMemberStore_CreateFromInvite_Call) Return(_a0 error) *mockMemberSt return _c } -func (_c *mockMemberStore_CreateFromInvite_Call) RunAndReturn(run func(context.Context, *actor.MemberInvite) error) *mockMemberStore_CreateFromInvite_Call { +func (_c *mockMemberStore_CreateFromInvite_Call) RunAndReturn(run func(context.Context, *supporterdata.MemberInvite) error) *mockMemberStore_CreateFromInvite_Call { _c.Call.Return(run) return _c } // CreateMemberInvite provides a mock function with given fields: ctx, organisation, firstNames, lastname, email, code, permission -func (_m *mockMemberStore) CreateMemberInvite(ctx context.Context, organisation *actor.Organisation, firstNames string, lastname string, email string, code string, permission actor.Permission) error { +func (_m *mockMemberStore) CreateMemberInvite(ctx context.Context, organisation *supporterdata.Organisation, firstNames string, lastname string, email string, code string, permission supporterdata.Permission) error { ret := _m.Called(ctx, organisation, firstNames, lastname, email, code, permission) if len(ret) == 0 { @@ -139,7 +138,7 @@ func (_m *mockMemberStore) CreateMemberInvite(ctx context.Context, organisation } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *actor.Organisation, string, string, string, string, actor.Permission) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *supporterdata.Organisation, string, string, string, string, supporterdata.Permission) error); ok { r0 = rf(ctx, organisation, firstNames, lastname, email, code, permission) } else { r0 = ret.Error(0) @@ -155,19 +154,19 @@ type mockMemberStore_CreateMemberInvite_Call struct { // CreateMemberInvite is a helper method to define mock.On call // - ctx context.Context -// - organisation *actor.Organisation +// - organisation *supporterdata.Organisation // - firstNames string // - lastname string // - email string // - code string -// - permission actor.Permission +// - permission supporterdata.Permission func (_e *mockMemberStore_Expecter) CreateMemberInvite(ctx interface{}, organisation interface{}, firstNames interface{}, lastname interface{}, email interface{}, code interface{}, permission interface{}) *mockMemberStore_CreateMemberInvite_Call { return &mockMemberStore_CreateMemberInvite_Call{Call: _e.mock.On("CreateMemberInvite", ctx, organisation, firstNames, lastname, email, code, permission)} } -func (_c *mockMemberStore_CreateMemberInvite_Call) Run(run func(ctx context.Context, organisation *actor.Organisation, firstNames string, lastname string, email string, code string, permission actor.Permission)) *mockMemberStore_CreateMemberInvite_Call { +func (_c *mockMemberStore_CreateMemberInvite_Call) Run(run func(ctx context.Context, organisation *supporterdata.Organisation, firstNames string, lastname string, email string, code string, permission supporterdata.Permission)) *mockMemberStore_CreateMemberInvite_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*actor.Organisation), args[2].(string), args[3].(string), args[4].(string), args[5].(string), args[6].(actor.Permission)) + run(args[0].(context.Context), args[1].(*supporterdata.Organisation), args[2].(string), args[3].(string), args[4].(string), args[5].(string), args[6].(supporterdata.Permission)) }) return _c } @@ -177,7 +176,7 @@ func (_c *mockMemberStore_CreateMemberInvite_Call) Return(_a0 error) *mockMember return _c } -func (_c *mockMemberStore_CreateMemberInvite_Call) RunAndReturn(run func(context.Context, *actor.Organisation, string, string, string, string, actor.Permission) error) *mockMemberStore_CreateMemberInvite_Call { +func (_c *mockMemberStore_CreateMemberInvite_Call) RunAndReturn(run func(context.Context, *supporterdata.Organisation, string, string, string, string, supporterdata.Permission) error) *mockMemberStore_CreateMemberInvite_Call { _c.Call.Return(run) return _c } @@ -231,23 +230,23 @@ func (_c *mockMemberStore_DeleteMemberInvite_Call) RunAndReturn(run func(context } // Get provides a mock function with given fields: ctx -func (_m *mockMemberStore) Get(ctx context.Context) (*actor.Member, error) { +func (_m *mockMemberStore) Get(ctx context.Context) (*supporterdata.Member, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *actor.Member + var r0 *supporterdata.Member var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*actor.Member, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*supporterdata.Member, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *actor.Member); ok { + if rf, ok := ret.Get(0).(func(context.Context) *supporterdata.Member); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*actor.Member) + r0 = ret.Get(0).(*supporterdata.Member) } } @@ -278,34 +277,34 @@ func (_c *mockMemberStore_Get_Call) Run(run func(ctx context.Context)) *mockMemb return _c } -func (_c *mockMemberStore_Get_Call) Return(_a0 *actor.Member, _a1 error) *mockMemberStore_Get_Call { +func (_c *mockMemberStore_Get_Call) Return(_a0 *supporterdata.Member, _a1 error) *mockMemberStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockMemberStore_Get_Call) RunAndReturn(run func(context.Context) (*actor.Member, error)) *mockMemberStore_Get_Call { +func (_c *mockMemberStore_Get_Call) RunAndReturn(run func(context.Context) (*supporterdata.Member, error)) *mockMemberStore_Get_Call { _c.Call.Return(run) return _c } // GetAll provides a mock function with given fields: ctx -func (_m *mockMemberStore) GetAll(ctx context.Context) ([]*actor.Member, error) { +func (_m *mockMemberStore) GetAll(ctx context.Context) ([]*supporterdata.Member, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetAll") } - var r0 []*actor.Member + var r0 []*supporterdata.Member var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]*actor.Member, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) ([]*supporterdata.Member, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) []*actor.Member); ok { + if rf, ok := ret.Get(0).(func(context.Context) []*supporterdata.Member); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*actor.Member) + r0 = ret.Get(0).([]*supporterdata.Member) } } @@ -336,34 +335,34 @@ func (_c *mockMemberStore_GetAll_Call) Run(run func(ctx context.Context)) *mockM return _c } -func (_c *mockMemberStore_GetAll_Call) Return(_a0 []*actor.Member, _a1 error) *mockMemberStore_GetAll_Call { +func (_c *mockMemberStore_GetAll_Call) Return(_a0 []*supporterdata.Member, _a1 error) *mockMemberStore_GetAll_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockMemberStore_GetAll_Call) RunAndReturn(run func(context.Context) ([]*actor.Member, error)) *mockMemberStore_GetAll_Call { +func (_c *mockMemberStore_GetAll_Call) RunAndReturn(run func(context.Context) ([]*supporterdata.Member, error)) *mockMemberStore_GetAll_Call { _c.Call.Return(run) return _c } // GetAny provides a mock function with given fields: ctx -func (_m *mockMemberStore) GetAny(ctx context.Context) (*actor.Member, error) { +func (_m *mockMemberStore) GetAny(ctx context.Context) (*supporterdata.Member, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetAny") } - var r0 *actor.Member + var r0 *supporterdata.Member var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*actor.Member, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*supporterdata.Member, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *actor.Member); ok { + if rf, ok := ret.Get(0).(func(context.Context) *supporterdata.Member); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*actor.Member) + r0 = ret.Get(0).(*supporterdata.Member) } } @@ -394,34 +393,34 @@ func (_c *mockMemberStore_GetAny_Call) Run(run func(ctx context.Context)) *mockM return _c } -func (_c *mockMemberStore_GetAny_Call) Return(_a0 *actor.Member, _a1 error) *mockMemberStore_GetAny_Call { +func (_c *mockMemberStore_GetAny_Call) Return(_a0 *supporterdata.Member, _a1 error) *mockMemberStore_GetAny_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockMemberStore_GetAny_Call) RunAndReturn(run func(context.Context) (*actor.Member, error)) *mockMemberStore_GetAny_Call { +func (_c *mockMemberStore_GetAny_Call) RunAndReturn(run func(context.Context) (*supporterdata.Member, error)) *mockMemberStore_GetAny_Call { _c.Call.Return(run) return _c } // GetByID provides a mock function with given fields: ctx, memberID -func (_m *mockMemberStore) GetByID(ctx context.Context, memberID string) (*actor.Member, error) { +func (_m *mockMemberStore) GetByID(ctx context.Context, memberID string) (*supporterdata.Member, error) { ret := _m.Called(ctx, memberID) if len(ret) == 0 { panic("no return value specified for GetByID") } - var r0 *actor.Member + var r0 *supporterdata.Member var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*actor.Member, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) (*supporterdata.Member, error)); ok { return rf(ctx, memberID) } - if rf, ok := ret.Get(0).(func(context.Context, string) *actor.Member); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) *supporterdata.Member); ok { r0 = rf(ctx, memberID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*actor.Member) + r0 = ret.Get(0).(*supporterdata.Member) } } @@ -453,34 +452,34 @@ func (_c *mockMemberStore_GetByID_Call) Run(run func(ctx context.Context, member return _c } -func (_c *mockMemberStore_GetByID_Call) Return(_a0 *actor.Member, _a1 error) *mockMemberStore_GetByID_Call { +func (_c *mockMemberStore_GetByID_Call) Return(_a0 *supporterdata.Member, _a1 error) *mockMemberStore_GetByID_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockMemberStore_GetByID_Call) RunAndReturn(run func(context.Context, string) (*actor.Member, error)) *mockMemberStore_GetByID_Call { +func (_c *mockMemberStore_GetByID_Call) RunAndReturn(run func(context.Context, string) (*supporterdata.Member, error)) *mockMemberStore_GetByID_Call { _c.Call.Return(run) return _c } // InvitedMember provides a mock function with given fields: ctx -func (_m *mockMemberStore) InvitedMember(ctx context.Context) (*actor.MemberInvite, error) { +func (_m *mockMemberStore) InvitedMember(ctx context.Context) (*supporterdata.MemberInvite, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for InvitedMember") } - var r0 *actor.MemberInvite + var r0 *supporterdata.MemberInvite var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*actor.MemberInvite, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*supporterdata.MemberInvite, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *actor.MemberInvite); ok { + if rf, ok := ret.Get(0).(func(context.Context) *supporterdata.MemberInvite); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*actor.MemberInvite) + r0 = ret.Get(0).(*supporterdata.MemberInvite) } } @@ -511,34 +510,34 @@ func (_c *mockMemberStore_InvitedMember_Call) Run(run func(ctx context.Context)) return _c } -func (_c *mockMemberStore_InvitedMember_Call) Return(_a0 *actor.MemberInvite, _a1 error) *mockMemberStore_InvitedMember_Call { +func (_c *mockMemberStore_InvitedMember_Call) Return(_a0 *supporterdata.MemberInvite, _a1 error) *mockMemberStore_InvitedMember_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockMemberStore_InvitedMember_Call) RunAndReturn(run func(context.Context) (*actor.MemberInvite, error)) *mockMemberStore_InvitedMember_Call { +func (_c *mockMemberStore_InvitedMember_Call) RunAndReturn(run func(context.Context) (*supporterdata.MemberInvite, error)) *mockMemberStore_InvitedMember_Call { _c.Call.Return(run) return _c } // InvitedMembers provides a mock function with given fields: ctx -func (_m *mockMemberStore) InvitedMembers(ctx context.Context) ([]*actor.MemberInvite, error) { +func (_m *mockMemberStore) InvitedMembers(ctx context.Context) ([]*supporterdata.MemberInvite, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for InvitedMembers") } - var r0 []*actor.MemberInvite + var r0 []*supporterdata.MemberInvite var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]*actor.MemberInvite, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) ([]*supporterdata.MemberInvite, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) []*actor.MemberInvite); ok { + if rf, ok := ret.Get(0).(func(context.Context) []*supporterdata.MemberInvite); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*actor.MemberInvite) + r0 = ret.Get(0).([]*supporterdata.MemberInvite) } } @@ -569,34 +568,34 @@ func (_c *mockMemberStore_InvitedMembers_Call) Run(run func(ctx context.Context) return _c } -func (_c *mockMemberStore_InvitedMembers_Call) Return(_a0 []*actor.MemberInvite, _a1 error) *mockMemberStore_InvitedMembers_Call { +func (_c *mockMemberStore_InvitedMembers_Call) Return(_a0 []*supporterdata.MemberInvite, _a1 error) *mockMemberStore_InvitedMembers_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockMemberStore_InvitedMembers_Call) RunAndReturn(run func(context.Context) ([]*actor.MemberInvite, error)) *mockMemberStore_InvitedMembers_Call { +func (_c *mockMemberStore_InvitedMembers_Call) RunAndReturn(run func(context.Context) ([]*supporterdata.MemberInvite, error)) *mockMemberStore_InvitedMembers_Call { _c.Call.Return(run) return _c } // InvitedMembersByEmail provides a mock function with given fields: ctx -func (_m *mockMemberStore) InvitedMembersByEmail(ctx context.Context) ([]*actor.MemberInvite, error) { +func (_m *mockMemberStore) InvitedMembersByEmail(ctx context.Context) ([]*supporterdata.MemberInvite, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for InvitedMembersByEmail") } - var r0 []*actor.MemberInvite + var r0 []*supporterdata.MemberInvite var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]*actor.MemberInvite, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) ([]*supporterdata.MemberInvite, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) []*actor.MemberInvite); ok { + if rf, ok := ret.Get(0).(func(context.Context) []*supporterdata.MemberInvite); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*actor.MemberInvite) + r0 = ret.Get(0).([]*supporterdata.MemberInvite) } } @@ -627,18 +626,18 @@ func (_c *mockMemberStore_InvitedMembersByEmail_Call) Run(run func(ctx context.C return _c } -func (_c *mockMemberStore_InvitedMembersByEmail_Call) Return(_a0 []*actor.MemberInvite, _a1 error) *mockMemberStore_InvitedMembersByEmail_Call { +func (_c *mockMemberStore_InvitedMembersByEmail_Call) Return(_a0 []*supporterdata.MemberInvite, _a1 error) *mockMemberStore_InvitedMembersByEmail_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockMemberStore_InvitedMembersByEmail_Call) RunAndReturn(run func(context.Context) ([]*actor.MemberInvite, error)) *mockMemberStore_InvitedMembersByEmail_Call { +func (_c *mockMemberStore_InvitedMembersByEmail_Call) RunAndReturn(run func(context.Context) ([]*supporterdata.MemberInvite, error)) *mockMemberStore_InvitedMembersByEmail_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, member -func (_m *mockMemberStore) Put(ctx context.Context, member *actor.Member) error { +func (_m *mockMemberStore) Put(ctx context.Context, member *supporterdata.Member) error { ret := _m.Called(ctx, member) if len(ret) == 0 { @@ -646,7 +645,7 @@ func (_m *mockMemberStore) Put(ctx context.Context, member *actor.Member) error } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *actor.Member) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *supporterdata.Member) error); ok { r0 = rf(ctx, member) } else { r0 = ret.Error(0) @@ -662,14 +661,14 @@ type mockMemberStore_Put_Call struct { // Put is a helper method to define mock.On call // - ctx context.Context -// - member *actor.Member +// - member *supporterdata.Member func (_e *mockMemberStore_Expecter) Put(ctx interface{}, member interface{}) *mockMemberStore_Put_Call { return &mockMemberStore_Put_Call{Call: _e.mock.On("Put", ctx, member)} } -func (_c *mockMemberStore_Put_Call) Run(run func(ctx context.Context, member *actor.Member)) *mockMemberStore_Put_Call { +func (_c *mockMemberStore_Put_Call) Run(run func(ctx context.Context, member *supporterdata.Member)) *mockMemberStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*actor.Member)) + run(args[0].(context.Context), args[1].(*supporterdata.Member)) }) return _c } @@ -679,7 +678,7 @@ func (_c *mockMemberStore_Put_Call) Return(_a0 error) *mockMemberStore_Put_Call return _c } -func (_c *mockMemberStore_Put_Call) RunAndReturn(run func(context.Context, *actor.Member) error) *mockMemberStore_Put_Call { +func (_c *mockMemberStore_Put_Call) RunAndReturn(run func(context.Context, *supporterdata.Member) error) *mockMemberStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/page/supporter/mock_NotifyClient_test.go b/internal/supporter/supporterpage/mock_NotifyClient_test.go similarity index 99% rename from internal/page/supporter/mock_NotifyClient_test.go rename to internal/supporter/supporterpage/mock_NotifyClient_test.go index dab230c1db..483a335614 100644 --- a/internal/page/supporter/mock_NotifyClient_test.go +++ b/internal/supporter/supporterpage/mock_NotifyClient_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" diff --git a/internal/page/supporter/mock_OneLoginClient_test.go b/internal/supporter/supporterpage/mock_OneLoginClient_test.go similarity index 99% rename from internal/page/supporter/mock_OneLoginClient_test.go rename to internal/supporter/supporterpage/mock_OneLoginClient_test.go index bf742d8802..409ac8675b 100644 --- a/internal/page/supporter/mock_OneLoginClient_test.go +++ b/internal/supporter/supporterpage/mock_OneLoginClient_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" diff --git a/internal/page/supporter/mock_OrganisationStore_test.go b/internal/supporter/supporterpage/mock_OrganisationStore_test.go similarity index 74% rename from internal/page/supporter/mock_OrganisationStore_test.go rename to internal/supporter/supporterpage/mock_OrganisationStore_test.go index 8157c66678..87cd48e26e 100644 --- a/internal/page/supporter/mock_OrganisationStore_test.go +++ b/internal/supporter/supporterpage/mock_OrganisationStore_test.go @@ -1,15 +1,14 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" - actor "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" - donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - mock "github.com/stretchr/testify/mock" + + supporterdata "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" ) // mockOrganisationStore is an autogenerated mock type for the OrganisationStore type @@ -26,27 +25,27 @@ func (_m *mockOrganisationStore) EXPECT() *mockOrganisationStore_Expecter { } // Create provides a mock function with given fields: ctx, member, name -func (_m *mockOrganisationStore) Create(ctx context.Context, member *actor.Member, name string) (*actor.Organisation, error) { +func (_m *mockOrganisationStore) Create(ctx context.Context, member *supporterdata.Member, name string) (*supporterdata.Organisation, error) { ret := _m.Called(ctx, member, name) if len(ret) == 0 { panic("no return value specified for Create") } - var r0 *actor.Organisation + var r0 *supporterdata.Organisation var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *actor.Member, string) (*actor.Organisation, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *supporterdata.Member, string) (*supporterdata.Organisation, error)); ok { return rf(ctx, member, name) } - if rf, ok := ret.Get(0).(func(context.Context, *actor.Member, string) *actor.Organisation); ok { + if rf, ok := ret.Get(0).(func(context.Context, *supporterdata.Member, string) *supporterdata.Organisation); ok { r0 = rf(ctx, member, name) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*actor.Organisation) + r0 = ret.Get(0).(*supporterdata.Organisation) } } - if rf, ok := ret.Get(1).(func(context.Context, *actor.Member, string) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *supporterdata.Member, string) error); ok { r1 = rf(ctx, member, name) } else { r1 = ret.Error(1) @@ -62,25 +61,25 @@ type mockOrganisationStore_Create_Call struct { // Create is a helper method to define mock.On call // - ctx context.Context -// - member *actor.Member +// - member *supporterdata.Member // - name string func (_e *mockOrganisationStore_Expecter) Create(ctx interface{}, member interface{}, name interface{}) *mockOrganisationStore_Create_Call { return &mockOrganisationStore_Create_Call{Call: _e.mock.On("Create", ctx, member, name)} } -func (_c *mockOrganisationStore_Create_Call) Run(run func(ctx context.Context, member *actor.Member, name string)) *mockOrganisationStore_Create_Call { +func (_c *mockOrganisationStore_Create_Call) Run(run func(ctx context.Context, member *supporterdata.Member, name string)) *mockOrganisationStore_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*actor.Member), args[2].(string)) + run(args[0].(context.Context), args[1].(*supporterdata.Member), args[2].(string)) }) return _c } -func (_c *mockOrganisationStore_Create_Call) Return(_a0 *actor.Organisation, _a1 error) *mockOrganisationStore_Create_Call { +func (_c *mockOrganisationStore_Create_Call) Return(_a0 *supporterdata.Organisation, _a1 error) *mockOrganisationStore_Create_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockOrganisationStore_Create_Call) RunAndReturn(run func(context.Context, *actor.Member, string) (*actor.Organisation, error)) *mockOrganisationStore_Create_Call { +func (_c *mockOrganisationStore_Create_Call) RunAndReturn(run func(context.Context, *supporterdata.Member, string) (*supporterdata.Organisation, error)) *mockOrganisationStore_Create_Call { _c.Call.Return(run) return _c } @@ -144,23 +143,23 @@ func (_c *mockOrganisationStore_CreateLPA_Call) RunAndReturn(run func(context.Co } // Get provides a mock function with given fields: ctx -func (_m *mockOrganisationStore) Get(ctx context.Context) (*actor.Organisation, error) { +func (_m *mockOrganisationStore) Get(ctx context.Context) (*supporterdata.Organisation, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *actor.Organisation + var r0 *supporterdata.Organisation var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*actor.Organisation, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*supporterdata.Organisation, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *actor.Organisation); ok { + if rf, ok := ret.Get(0).(func(context.Context) *supporterdata.Organisation); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*actor.Organisation) + r0 = ret.Get(0).(*supporterdata.Organisation) } } @@ -191,18 +190,18 @@ func (_c *mockOrganisationStore_Get_Call) Run(run func(ctx context.Context)) *mo return _c } -func (_c *mockOrganisationStore_Get_Call) Return(_a0 *actor.Organisation, _a1 error) *mockOrganisationStore_Get_Call { +func (_c *mockOrganisationStore_Get_Call) Return(_a0 *supporterdata.Organisation, _a1 error) *mockOrganisationStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockOrganisationStore_Get_Call) RunAndReturn(run func(context.Context) (*actor.Organisation, error)) *mockOrganisationStore_Get_Call { +func (_c *mockOrganisationStore_Get_Call) RunAndReturn(run func(context.Context) (*supporterdata.Organisation, error)) *mockOrganisationStore_Get_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, organisation -func (_m *mockOrganisationStore) Put(ctx context.Context, organisation *actor.Organisation) error { +func (_m *mockOrganisationStore) Put(ctx context.Context, organisation *supporterdata.Organisation) error { ret := _m.Called(ctx, organisation) if len(ret) == 0 { @@ -210,7 +209,7 @@ func (_m *mockOrganisationStore) Put(ctx context.Context, organisation *actor.Or } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *actor.Organisation) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *supporterdata.Organisation) error); ok { r0 = rf(ctx, organisation) } else { r0 = ret.Error(0) @@ -226,14 +225,14 @@ type mockOrganisationStore_Put_Call struct { // Put is a helper method to define mock.On call // - ctx context.Context -// - organisation *actor.Organisation +// - organisation *supporterdata.Organisation func (_e *mockOrganisationStore_Expecter) Put(ctx interface{}, organisation interface{}) *mockOrganisationStore_Put_Call { return &mockOrganisationStore_Put_Call{Call: _e.mock.On("Put", ctx, organisation)} } -func (_c *mockOrganisationStore_Put_Call) Run(run func(ctx context.Context, organisation *actor.Organisation)) *mockOrganisationStore_Put_Call { +func (_c *mockOrganisationStore_Put_Call) Run(run func(ctx context.Context, organisation *supporterdata.Organisation)) *mockOrganisationStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*actor.Organisation)) + run(args[0].(context.Context), args[1].(*supporterdata.Organisation)) }) return _c } @@ -243,13 +242,13 @@ func (_c *mockOrganisationStore_Put_Call) Return(_a0 error) *mockOrganisationSto return _c } -func (_c *mockOrganisationStore_Put_Call) RunAndReturn(run func(context.Context, *actor.Organisation) error) *mockOrganisationStore_Put_Call { +func (_c *mockOrganisationStore_Put_Call) RunAndReturn(run func(context.Context, *supporterdata.Organisation) error) *mockOrganisationStore_Put_Call { _c.Call.Return(run) return _c } // SoftDelete provides a mock function with given fields: ctx, organisation -func (_m *mockOrganisationStore) SoftDelete(ctx context.Context, organisation *actor.Organisation) error { +func (_m *mockOrganisationStore) SoftDelete(ctx context.Context, organisation *supporterdata.Organisation) error { ret := _m.Called(ctx, organisation) if len(ret) == 0 { @@ -257,7 +256,7 @@ func (_m *mockOrganisationStore) SoftDelete(ctx context.Context, organisation *a } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *actor.Organisation) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *supporterdata.Organisation) error); ok { r0 = rf(ctx, organisation) } else { r0 = ret.Error(0) @@ -273,14 +272,14 @@ type mockOrganisationStore_SoftDelete_Call struct { // SoftDelete is a helper method to define mock.On call // - ctx context.Context -// - organisation *actor.Organisation +// - organisation *supporterdata.Organisation func (_e *mockOrganisationStore_Expecter) SoftDelete(ctx interface{}, organisation interface{}) *mockOrganisationStore_SoftDelete_Call { return &mockOrganisationStore_SoftDelete_Call{Call: _e.mock.On("SoftDelete", ctx, organisation)} } -func (_c *mockOrganisationStore_SoftDelete_Call) Run(run func(ctx context.Context, organisation *actor.Organisation)) *mockOrganisationStore_SoftDelete_Call { +func (_c *mockOrganisationStore_SoftDelete_Call) Run(run func(ctx context.Context, organisation *supporterdata.Organisation)) *mockOrganisationStore_SoftDelete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*actor.Organisation)) + run(args[0].(context.Context), args[1].(*supporterdata.Organisation)) }) return _c } @@ -290,7 +289,7 @@ func (_c *mockOrganisationStore_SoftDelete_Call) Return(_a0 error) *mockOrganisa return _c } -func (_c *mockOrganisationStore_SoftDelete_Call) RunAndReturn(run func(context.Context, *actor.Organisation) error) *mockOrganisationStore_SoftDelete_Call { +func (_c *mockOrganisationStore_SoftDelete_Call) RunAndReturn(run func(context.Context, *supporterdata.Organisation) error) *mockOrganisationStore_SoftDelete_Call { _c.Call.Return(run) return _c } diff --git a/internal/page/supporter/mock_ProgressTracker_test.go b/internal/supporter/supporterpage/mock_ProgressTracker_test.go similarity index 99% rename from internal/page/supporter/mock_ProgressTracker_test.go rename to internal/supporter/supporterpage/mock_ProgressTracker_test.go index 43693f1674..259046c282 100644 --- a/internal/page/supporter/mock_ProgressTracker_test.go +++ b/internal/supporter/supporterpage/mock_ProgressTracker_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" diff --git a/internal/page/supporter/mock_SearchClient_test.go b/internal/supporter/supporterpage/mock_SearchClient_test.go similarity index 99% rename from internal/page/supporter/mock_SearchClient_test.go rename to internal/supporter/supporterpage/mock_SearchClient_test.go index d499173842..72db54092e 100644 --- a/internal/page/supporter/mock_SearchClient_test.go +++ b/internal/supporter/supporterpage/mock_SearchClient_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" diff --git a/internal/page/supporter/mock_SessionStore_test.go b/internal/supporter/supporterpage/mock_SessionStore_test.go similarity index 99% rename from internal/page/supporter/mock_SessionStore_test.go rename to internal/supporter/supporterpage/mock_SessionStore_test.go index f34e70e6e8..484074aca4 100644 --- a/internal/page/supporter/mock_SessionStore_test.go +++ b/internal/supporter/supporterpage/mock_SessionStore_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( http "net/http" diff --git a/internal/page/supporter/mock_ShareCodeStore_test.go b/internal/supporter/supporterpage/mock_ShareCodeStore_test.go similarity index 99% rename from internal/page/supporter/mock_ShareCodeStore_test.go rename to internal/supporter/supporterpage/mock_ShareCodeStore_test.go index aa45031e63..fdc6ac3fcc 100644 --- a/internal/page/supporter/mock_ShareCodeStore_test.go +++ b/internal/supporter/supporterpage/mock_ShareCodeStore_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( context "context" diff --git a/internal/page/supporter/mock_SupporterPath_test.go b/internal/supporter/supporterpage/mock_SupporterPath_test.go similarity index 99% rename from internal/page/supporter/mock_SupporterPath_test.go rename to internal/supporter/supporterpage/mock_SupporterPath_test.go index 0aabf0dab5..b676f7c08b 100644 --- a/internal/page/supporter/mock_SupporterPath_test.go +++ b/internal/supporter/supporterpage/mock_SupporterPath_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import mock "github.com/stretchr/testify/mock" diff --git a/internal/page/supporter/mock_Template_test.go b/internal/supporter/supporterpage/mock_Template_test.go similarity index 98% rename from internal/page/supporter/mock_Template_test.go rename to internal/supporter/supporterpage/mock_Template_test.go index c39510c21e..65052d3d9f 100644 --- a/internal/page/supporter/mock_Template_test.go +++ b/internal/supporter/supporterpage/mock_Template_test.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.42.2. DO NOT EDIT. -package supporter +package supporterpage import ( io "io" diff --git a/internal/page/supporter/mock_test.go b/internal/supporter/supporterpage/mock_test.go similarity index 81% rename from internal/page/supporter/mock_test.go rename to internal/supporter/supporterpage/mock_test.go index a4044db9af..60ecc28e2f 100644 --- a/internal/page/supporter/mock_test.go +++ b/internal/supporter/supporterpage/mock_test.go @@ -1,11 +1,11 @@ -package supporter +package supporterpage import ( "errors" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" ) var ( @@ -18,7 +18,7 @@ var ( LoginSessionEmail: "supporter@example.com", SupporterData: &appcontext.SupporterData{ OrganisationName: "My organisation", - Permission: actor.PermissionNone, + Permission: supporterdata.PermissionNone, LoggedInSupporterID: "supporter-id", }, } diff --git a/internal/page/supporter/register.go b/internal/supporter/supporterpage/register.go similarity index 88% rename from internal/page/supporter/register.go rename to internal/supporter/supporterpage/register.go index ecf9c126e2..98d985128f 100644 --- a/internal/page/supporter/register.go +++ b/internal/supporter/supporterpage/register.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "context" @@ -8,7 +8,6 @@ import ( "time" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" @@ -21,6 +20,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -33,26 +33,26 @@ type LpaStoreResolvingService interface { } type OrganisationStore interface { - Create(ctx context.Context, member *actor.Member, name string) (*actor.Organisation, error) + Create(ctx context.Context, member *supporterdata.Member, name string) (*supporterdata.Organisation, error) CreateLPA(ctx context.Context) (*donordata.Provided, error) - Get(ctx context.Context) (*actor.Organisation, error) - Put(ctx context.Context, organisation *actor.Organisation) error - SoftDelete(ctx context.Context, organisation *actor.Organisation) error + Get(ctx context.Context) (*supporterdata.Organisation, error) + Put(ctx context.Context, organisation *supporterdata.Organisation) error + SoftDelete(ctx context.Context, organisation *supporterdata.Organisation) error } type MemberStore interface { - Create(ctx context.Context, firstNames, lastName string) (*actor.Member, error) - CreateFromInvite(ctx context.Context, invite *actor.MemberInvite) error - CreateMemberInvite(ctx context.Context, organisation *actor.Organisation, firstNames, lastname, email, code string, permission actor.Permission) error + Create(ctx context.Context, firstNames, lastName string) (*supporterdata.Member, error) + CreateFromInvite(ctx context.Context, invite *supporterdata.MemberInvite) error + CreateMemberInvite(ctx context.Context, organisation *supporterdata.Organisation, firstNames, lastname, email, code string, permission supporterdata.Permission) error DeleteMemberInvite(ctx context.Context, organisationID, email string) error - Get(ctx context.Context) (*actor.Member, error) - GetAny(ctx context.Context) (*actor.Member, error) - GetAll(ctx context.Context) ([]*actor.Member, error) - GetByID(ctx context.Context, memberID string) (*actor.Member, error) - InvitedMember(ctx context.Context) (*actor.MemberInvite, error) - InvitedMembers(ctx context.Context) ([]*actor.MemberInvite, error) - InvitedMembersByEmail(ctx context.Context) ([]*actor.MemberInvite, error) - Put(ctx context.Context, member *actor.Member) error + Get(ctx context.Context) (*supporterdata.Member, error) + GetAny(ctx context.Context) (*supporterdata.Member, error) + GetAll(ctx context.Context) ([]*supporterdata.Member, error) + GetByID(ctx context.Context, memberID string) (*supporterdata.Member, error) + InvitedMember(ctx context.Context) (*supporterdata.MemberInvite, error) + InvitedMembers(ctx context.Context) ([]*supporterdata.MemberInvite, error) + InvitedMembersByEmail(ctx context.Context) ([]*supporterdata.MemberInvite, error) + Put(ctx context.Context, member *supporterdata.Member) error } type DonorStore interface { @@ -96,7 +96,7 @@ type ShareCodeStore interface { type Template func(w io.Writer, data interface{}) error -type Handler func(data appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, member *actor.Member) error +type Handler func(data appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, member *supporterdata.Member) error type ErrorHandler func(http.ResponseWriter, *http.Request, error) diff --git a/internal/page/supporter/register_test.go b/internal/supporter/supporterpage/register_test.go similarity index 89% rename from internal/page/supporter/register_test.go rename to internal/supporter/supporterpage/register_test.go index c4634e9513..749a6c06a3 100644 --- a/internal/page/supporter/register_test.go +++ b/internal/supporter/supporterpage/register_test.go @@ -1,4 +1,4 @@ -package supporter +package supporterpage import ( "context" @@ -7,7 +7,6 @@ import ( "testing" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" @@ -15,6 +14,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -131,20 +131,20 @@ func TestMakeSupporterHandle(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Organisation{ID: "org-id"}, nil) + Return(&supporterdata.Organisation{ID: "org-id"}, nil) memberStore := newMockMemberStore(t) memberStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Member{Permission: actor.PermissionAdmin, ID: "member-id"}, nil) + Return(&supporterdata.Member{Permission: supporterdata.PermissionAdmin, ID: "member-id"}, nil) handle := makeSupporterHandle(mux, sessionStore, nil, organisationStore, memberStore, nil) - handle(page.SupporterPath("/path"), CanGoBack, func(appData appcontext.Data, hw http.ResponseWriter, hr *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + handle(page.SupporterPath("/path"), CanGoBack, func(appData appcontext.Data, hw http.ResponseWriter, hr *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { assert.Equal(t, appcontext.Data{ Page: "/supporter/path", SessionID: "cmFuZG9t", SupporterData: &appcontext.SupporterData{ - Permission: actor.PermissionAdmin, + Permission: supporterdata.PermissionAdmin, LoggedInSupporterID: "member-id", }, CanGoBack: true, @@ -181,20 +181,20 @@ func TestMakeSupporterHandleWithLpaPath(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Organisation{ID: "org-id"}, nil) + Return(&supporterdata.Organisation{ID: "org-id"}, nil) memberStore := newMockMemberStore(t) memberStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org", LpaID: "xyz"})). - Return(&actor.Member{Permission: actor.PermissionAdmin, ID: "member-id"}, nil) + Return(&supporterdata.Member{Permission: supporterdata.PermissionAdmin, ID: "member-id"}, nil) handle := makeSupporterHandle(mux, sessionStore, nil, organisationStore, memberStore, nil) - handle(page.SupporterLpaPath("/path"), CanGoBack, func(appData appcontext.Data, hw http.ResponseWriter, hr *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + handle(page.SupporterLpaPath("/path"), CanGoBack, func(appData appcontext.Data, hw http.ResponseWriter, hr *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { assert.Equal(t, appcontext.Data{ Page: "/supporter/path/xyz", SessionID: "cmFuZG9t", SupporterData: &appcontext.SupporterData{ - Permission: actor.PermissionAdmin, + Permission: supporterdata.PermissionAdmin, LoggedInSupporterID: "member-id", }, CanGoBack: true, @@ -232,20 +232,20 @@ func TestMakeSupporterHandleWhenRequireAdmin(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Organisation{ID: "org-id"}, nil) + Return(&supporterdata.Organisation{ID: "org-id"}, nil) memberStore := newMockMemberStore(t) memberStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Member{Permission: actor.PermissionAdmin, ID: "member-id"}, nil) + Return(&supporterdata.Member{Permission: supporterdata.PermissionAdmin, ID: "member-id"}, nil) handle := makeSupporterHandle(mux, sessionStore, nil, organisationStore, memberStore, nil) - handle(page.SupporterPath("/path"), RequireAdmin, func(appData appcontext.Data, hw http.ResponseWriter, hr *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + handle(page.SupporterPath("/path"), RequireAdmin, func(appData appcontext.Data, hw http.ResponseWriter, hr *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { assert.Equal(t, appcontext.Data{ Page: "/supporter/path", SessionID: "cmFuZG9t", SupporterData: &appcontext.SupporterData{ - Permission: actor.PermissionAdmin, + Permission: supporterdata.PermissionAdmin, LoggedInSupporterID: "member-id", }, LoginSessionEmail: "a@example.org", @@ -281,12 +281,12 @@ func TestMakeSupporterHandleWhenRequireAdminAsNonAdmin(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Organisation{ID: "org-id"}, nil) + Return(&supporterdata.Organisation{ID: "org-id"}, nil) memberStore := newMockMemberStore(t) memberStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Member{Permission: actor.PermissionNone, ID: "member-id"}, nil) + Return(&supporterdata.Member{Permission: supporterdata.PermissionNone, ID: "member-id"}, nil) errorHandler := newMockErrorHandler(t) errorHandler.EXPECT(). @@ -313,12 +313,12 @@ func TestMakeSupporterHandleWhenSuspended(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Organisation{ID: "org-id", Name: "My Org"}, nil) + Return(&supporterdata.Organisation{ID: "org-id", Name: "My Org"}, nil) memberStore := newMockMemberStore(t) memberStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Member{Permission: actor.PermissionAdmin, ID: "member-id", Status: actor.StatusSuspended}, nil) + Return(&supporterdata.Member{Permission: supporterdata.PermissionAdmin, ID: "member-id", Status: supporterdata.StatusSuspended}, nil) suspendedTmpl := newMockTemplate(t) suspendedTmpl.EXPECT(). @@ -357,12 +357,12 @@ func TestMakeSupporterHandleWhenSuspendedTemplateErrors(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Organisation{ID: "org-id", Name: "My Org"}, nil) + Return(&supporterdata.Organisation{ID: "org-id", Name: "My Org"}, nil) memberStore := newMockMemberStore(t) memberStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Member{Permission: actor.PermissionAdmin, ID: "member-id", Status: actor.StatusSuspended}, nil) + Return(&supporterdata.Member{Permission: supporterdata.PermissionAdmin, ID: "member-id", Status: supporterdata.StatusSuspended}, nil) suspendedTmpl := newMockTemplate(t) suspendedTmpl.EXPECT(). @@ -410,20 +410,20 @@ func TestMakeSupporterHandleWithSession(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id"})). - Return(&actor.Organisation{ID: "org-id"}, nil) + Return(&supporterdata.Organisation{ID: "org-id"}, nil) memberStore := newMockMemberStore(t) memberStore.EXPECT(). Get(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: "cmFuZG9t", OrganisationID: "org-id", Email: "a@example.org"})). - Return(&actor.Member{Permission: actor.PermissionAdmin, ID: "member-id"}, nil) + Return(&supporterdata.Member{Permission: supporterdata.PermissionAdmin, ID: "member-id"}, nil) handle := makeSupporterHandle(mux, sessionStore, nil, organisationStore, memberStore, nil) - handle(page.SupporterPath("/path"), None, func(appData appcontext.Data, hw http.ResponseWriter, hr *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + handle(page.SupporterPath("/path"), None, func(appData appcontext.Data, hw http.ResponseWriter, hr *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { assert.Equal(t, appcontext.Data{ Page: "/supporter/path", SessionID: "cmFuZG9t", SupporterData: &appcontext.SupporterData{ - Permission: actor.PermissionAdmin, + Permission: supporterdata.PermissionAdmin, LoggedInSupporterID: "member-id", }, LoginSessionEmail: "a@example.org", @@ -509,12 +509,12 @@ func TestMakeSupporterHandleWhenMemberStoreError(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(mock.Anything). - Return(&actor.Organisation{}, nil) + Return(&supporterdata.Organisation{}, nil) memberStore := newMockMemberStore(t) memberStore.EXPECT(). Get(mock.Anything). - Return(&actor.Member{}, expectedError) + Return(&supporterdata.Member{}, expectedError) handle := makeSupporterHandle(mux, sessionStore, errorHandler.Execute, organisationStore, memberStore, nil) handle(page.SupporterPath("/path"), None, nil) @@ -538,16 +538,16 @@ func TestMakeSupporterHandleErrors(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). Get(mock.Anything). - Return(&actor.Organisation{}, nil) + Return(&supporterdata.Organisation{}, nil) memberStore := newMockMemberStore(t) memberStore.EXPECT(). Get(mock.Anything). - Return(&actor.Member{}, nil) + Return(&supporterdata.Member{}, nil) mux := http.NewServeMux() handle := makeSupporterHandle(mux, sessionStore, errorHandler.Execute, organisationStore, memberStore, nil) - handle(page.SupporterPath("/path"), None, func(_ appcontext.Data, _ http.ResponseWriter, _ *http.Request, _ *actor.Organisation, _ *actor.Member) error { + handle(page.SupporterPath("/path"), None, func(_ appcontext.Data, _ http.ResponseWriter, _ *http.Request, _ *supporterdata.Organisation, _ *supporterdata.Member) error { return expectedError }) diff --git a/internal/page/supporter/view_lpa.go b/internal/supporter/supporterpage/view_lpa.go similarity index 82% rename from internal/page/supporter/view_lpa.go rename to internal/supporter/supporterpage/view_lpa.go index c8f2f53336..aa50b5e476 100644 --- a/internal/page/supporter/view_lpa.go +++ b/internal/supporter/supporterpage/view_lpa.go @@ -1,13 +1,13 @@ -package supporter +package supporterpage import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -19,7 +19,7 @@ type viewLPAData struct { } func ViewLPA(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, progressTracker ProgressTracker) Handler { - return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation, _ *actor.Member) error { + return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, organisation *supporterdata.Organisation, _ *supporterdata.Member) error { lpa, err := lpaStoreResolvingService.Get(r.Context()) if err != nil { return err diff --git a/internal/page/supporter/view_lpa_test.go b/internal/supporter/supporterpage/view_lpa_test.go similarity index 88% rename from internal/page/supporter/view_lpa_test.go rename to internal/supporter/supporterpage/view_lpa_test.go index 8a67d72c31..8882e58433 100644 --- a/internal/page/supporter/view_lpa_test.go +++ b/internal/supporter/supporterpage/view_lpa_test.go @@ -1,13 +1,13 @@ -package supporter +package supporterpage import ( "net/http" "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -38,7 +38,7 @@ func TestGetViewLPA(t *testing.T) { }). Return(nil) - err := ViewLPA(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &actor.Organisation{}, nil) + err := ViewLPA(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &supporterdata.Organisation{}, nil) assert.Nil(t, err) } @@ -52,7 +52,7 @@ func TestGetViewLPAWhenLpaStoreClientError(t *testing.T) { Get(r.Context()). Return(nil, expectedError) - err := ViewLPA(nil, lpaStoreResolvingService, nil)(testAppData, w, r, &actor.Organisation{}, nil) + err := ViewLPA(nil, lpaStoreResolvingService, nil)(testAppData, w, r, &supporterdata.Organisation{}, nil) assert.Error(t, err) } @@ -76,7 +76,7 @@ func TestGetViewLPAWhenTemplateError(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ViewLPA(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &actor.Organisation{}, nil) + err := ViewLPA(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &supporterdata.Organisation{}, nil) assert.Error(t, err) } diff --git a/internal/uid/mock_v4Signer_test.go b/internal/uid/mock_v4Signer_test.go deleted file mode 100644 index a27946a887..0000000000 --- a/internal/uid/mock_v4Signer_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. - -package uid - -import ( - context "context" - - aws "github.com/aws/aws-sdk-go-v2/aws" - - http "net/http" - - mock "github.com/stretchr/testify/mock" - - time "time" - - v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" -) - -// mockV4Signer is an autogenerated mock type for the v4Signer type -type mockV4Signer struct { - mock.Mock -} - -// SignHTTP provides a mock function with given fields: _a0, _a1, _a2, _a3, _a4, _a5, _a6, _a7 -func (_m *mockV4Signer) SignHTTP(_a0 context.Context, _a1 aws.Credentials, _a2 *http.Request, _a3 string, _a4 string, _a5 string, _a6 time.Time, _a7 ...func(*v4.SignerOptions)) error { - _va := make([]interface{}, len(_a7)) - for _i := range _a7 { - _va[_i] = _a7[_i] - } - var _ca []interface{} - _ca = append(_ca, _a0, _a1, _a2, _a3, _a4, _a5, _a6) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, aws.Credentials, *http.Request, string, string, string, time.Time, ...func(*v4.SignerOptions)) error); ok { - r0 = rf(_a0, _a1, _a2, _a3, _a4, _a5, _a6, _a7...) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTnewMockV4Signer interface { - mock.TestingT - Cleanup(func()) -} - -// newMockV4Signer creates a new instance of mockV4Signer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func newMockV4Signer(t mockConstructorTestingTnewMockV4Signer) *mockV4Signer { - mock := &mockV4Signer{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -}