Skip to content

Conversation

@deads2k
Copy link
Collaborator

@deads2k deads2k commented Jan 23, 2026

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.

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.
@openshift-ci
Copy link

openshift-ci bot commented Jan 23, 2026

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

}
}

func (m *mockResourceCRUD[InternalAPIType, CosmosAPIType]) makeResourceIDPath(resourceID string) (*azcorearm.ResourceID, error) {
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

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{
Copy link
Collaborator Author

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.

}

// MockFrontendIntegrationTestInfo holds test information when using a mock database.
type MockFrontendIntegrationTestInfo struct {
Copy link
Collaborator Author

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.

@openshift-ci
Copy link

openshift-ci bot commented Jan 23, 2026

@deads2k: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-parallel 587165c link true /test e2e-parallel

Full PR test history. Your PR dashboard.

Details

Instructions 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants