Skip to content

test(): correct mock client type and remove deprecated ClusterName field in tests#404

Open
Shreesha001 wants to merge 1 commit into
kubeslice:masterfrom
Shreesha001:fix/test-type-mismatch
Open

test(): correct mock client type and remove deprecated ClusterName field in tests#404
Shreesha001 wants to merge 1 commit into
kubeslice:masterfrom
Shreesha001:fix/test-type-mismatch

Conversation

@Shreesha001

Copy link
Copy Markdown

Description

Fixes build failures in test files caused by incorrect mock client type usage and deprecated Kubernetes API fields.

Changes

  • Replaced util.Client with *utilMock.Client in test helper functions , required for testify mocks to work correctly
  • Removed deprecated ClusterName field from ObjectMeta struct literals.

Fixes #

How Has This Been Tested?

  • Ran make unit-test
  • Verified that test packages compile successfully
  • Confirmed the previous build failures are resolved

Checklist

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit test cases.

Does this PR introduce a breaking change for other components like worker-operator?

No.

@pnavali pnavali requested review from Copilot and removed request for that-backend-guy July 1, 2026 18:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes unit-test build failures by updating test scaffolding to use the correct mock client type (so testify/mock expectations work) and by removing usage of a deprecated/removed Kubernetes API field in test object literals.

Changes:

  • Updated test helper context-preparation functions to accept *util/mocks.Client instead of the previously referenced util.Client.
  • Removed the deprecated ObjectMeta.ClusterName field from a metav1.ObjectMeta literal in a worker slice gateway service test.
  • Cleaned up testing import placement in access_control_service_test.go.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
service/worker_slice_gateway_service_test.go Removes deprecated ObjectMeta.ClusterName usage that can break builds with newer Kubernetes API versions.
service/project_service_test.go Adjusts helper signature to accept the actual testify mock client type used by tests.
service/namespace_service_test.go Adjusts helper signature to accept the actual testify mock client type used by tests.
service/access_control_service_test.go Adjusts helper signature to accept the actual testify mock client type used by tests and tidies imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

… in tests

Signed-off-by: Shreesha001 <shettyshreesha552@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

}

func prepareACSTestContext(ctx context.Context, client util.Client,
func prepareACSTestContext(ctx context.Context, client *utilMock.Client,
}

func prepareNamespaceTestContext(ctx context.Context, client util.Client, scheme *runtime.Scheme) context.Context {
func prepareNamespaceTestContext(ctx context.Context, client *utilMock.Client, scheme *runtime.Scheme) context.Context {
Comment on lines +279 to 280
func prepareProjectTestContext(ctx context.Context, client *utilMock.Client,
scheme *runtime.Scheme) context.Context {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants