Cover resource_data_record with unit tests #341
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request involves changes to the
internal/powerplatform/services/data_record/api_data_record.go
file, which is part of the data record service in the Power Platform. The changes mainly include updates to theApplyDataRecord
andDeleteDataRecord
functions, and theapplyRelations
function. Additionally, new test data has been added to multiple JSON files in theinternal/powerplatform/services/data_record/tests/resource/Validate_Create
directory.Here are the most significant changes:
Updates to
api_data_record.go
:func (client *DataRecordClient) ApplyDataRecord(ctx context.Context, recordId, e
: Changed the regex match fromFindStringSubmatch
toFindAllStringSubmatch
to capture all matches instead of just the first one. Also, updated theresult.Id
assignment to use the last match instead of the first one.func (client *DataRecordClient) ApplyDataRecord(ctx context.Context, recordId, e
: Removed the call toparseLocationHeader
function and the function itself, which was used to parse the location header from the API response. [1] [2]func applyRelations(ctx context.Context, client *DataRecordClient, relations map
: Added error handling for the API execution in theapplyRelations
function.Additions to test data:
internal/powerplatform/services/data_record/tests/resource/Validate_Create/get_account_00000000-0000-0000-0000-000000000020.json
: Added a new test data file for account validation.internal/powerplatform/services/data_record/tests/resource/Validate_Create/get_account_00000000-0000-0000-0000-000000000020_contact_customer_accounts.json
: Added a new test data file for account contact customer accounts validation.internal/powerplatform/services/data_record/tests/resource/Validate_Create/get_account_00000000-0000-0000-0000-000000000020_ref.json
: Added a new test data file for account reference validation.internal/powerplatform/services/data_record/tests/resource/Validate_Create/get_contact_00000000-0000-0000-0000-000000000010.json
: Added a new test data file for contact validation.[Copilot is generating a summary...]