-
Notifications
You must be signed in to change notification settings - Fork 105
Create a mock cosmos client that is capable to doing basic crud #3877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This will be the basis for unit tests for controllers that can wire in some basic cosmosclient. It is not intended as a replacement for cosmos emulator backed integration tests, though it is compatible to run those tests with a complete mock instead of a the emulator. We did that to have confidence that the cosmosClient mock is compatible with the actual client.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| } | ||
| } | ||
|
|
||
| func (m *mockResourceCRUD[InternalAPIType, CosmosAPIType]) makeResourceIDPath(resourceID string) (*azcorearm.ResourceID, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annoying to have this duplicated, not terrible, but annoying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't fix.
| return m.GetByID(ctx, cosmosID) | ||
| } | ||
|
|
||
| func (m *mockResourceCRUD[InternalAPIType, CosmosAPIType]) Replace(ctx context.Context, newObj *InternalAPIType, options *azcosmos.ItemOptions) (*InternalAPIType, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when we add etag support, we'll probably want to add that here.
| CosmosID: cosmosID, | ||
| } | ||
|
|
||
| mockTx.steps = append(mockTx.steps, mockTransactionStep{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet it doesn't rollback. I dont' really care.
test-integration/utils/databasemutationhelpers/resource_crud_test_util.go
Show resolved
Hide resolved
| } | ||
|
|
||
| // MockFrontendIntegrationTestInfo holds test information when using a mock database. | ||
| type MockFrontendIntegrationTestInfo struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to refine this so it replaces cosmos and not the entire thing.
|
@deads2k: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
This will be the basis for unit tests for controllers that can wire in some basic cosmosclient. It is not intended as a replacement for cosmos emulator backed integration tests, though it is compatible to run those tests with a complete mock instead of a the emulator. We did that to have confidence that the cosmosClient mock is compatible with the actual client.
/hold
I haven't yet reviewed what the AI gave me. I need to review this first.