Skip to content

Design Improvements[UTs]: Restructure and re-use helper functions #4971

@cmallikarjunah

Description

@cmallikarjunah

Design Improvements Description

We need to create a shared way across kubebuilder/pkg/ unittests and e2e tests to reuse functionality of creating/using binaries and temporary directory. That way we re-use the same code across files and reduce the overhead of modifying multiple areas from the maintenance perspective. Thus, also improving readability and structure.

Existing helper for binary creation:
https://github.com/kubernetes-sigs/kubebuilder/blob/869ca6b65027baa71f4d5410f68f7830c1c90857/test/e2e/utils/test_context.go#L64C1-L117C2

Existing helper for cleaning up dir: https://github.com/kubernetes-sigs/kubebuilder/blob/master/test/e2e/utils/test_context.go#L251-L270

Example Usage: https://github.com/kubernetes-sigs/kubebuilder/blob/869ca6b65027baa71f4d5410f68f7830c1c90857/test/e2e/v4/e2e_suite_test.go#L40-L43

What do we need

  1. We need something like test/context.go in our repo where the helpers can be placed.
  2. kubebuilder/pkg/ unit tests to use the contexts.
  3. Identify similar adjustments and add it to test/ and make sure we re-use code as much as possible for testing.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions