Skip to content

test: add unit tests for SetLabelsAndAnnotationsForWorkload and GetWorkSuspendDispatching in pkg/util/work.go #7673

Description

@Goutham-Annem

Description

Two functions in pkg/util/work.go currently lack unit test coverage:

  • SetLabelsAndAnnotationsForWorkload
  • GetWorkSuspendDispatching

Why This Is Needed

SetLabelsAndAnnotationsForWorkload copies labels and annotations from a Work object to a workload unstructured object. It contains merging logic that should be verified.

GetWorkSuspendDispatching extracts suspend dispatching cluster names from a WorkSpec. It handles both nil and non-nil spec, plus the case where the suspend condition is absent.

Adding tests ensures correctness and prevents regressions.

Solution

Add unit tests following existing test patterns in work_test.go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions