Skip to content

Refactor MachinePool unit tests to use Builder/Options#2252

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:masterfrom
2uasimojo:HIVE-2476/refactor-mp-ut-opts
Apr 4, 2024
Merged

Refactor MachinePool unit tests to use Builder/Options#2252
openshift-merge-bot[bot] merged 1 commit intoopenshift:masterfrom
2uasimojo:HIVE-2476/refactor-mp-ut-opts

Conversation

@2uasimojo
Copy link
Member

@2uasimojo 2uasimojo commented Apr 1, 2024

In preparation for expanding OpenStack-specific MachinePool unit tests, refactor the helper funcs in the existing suite to use the MachinePool "Builder" pattern with "Options". For example, we change this:

machinePool: func() *hivev1.MachinePool {
        mp := testMachinePoolWithoutLabelsTaints()
        mp.Spec.Labels = make(map[string]string)
        mp.Spec.Labels["test-label"] = "test-value"
        return mp
}(),

to:

machinePool: testMachinePoolWithoutLabelsTaints(
        testmp.WithLabels(map[string]string{
                "test-label": "test-value",
        }),
),

This makes the test code slightly tighter and more readable, and brings the suite more in line with our usual (or at least, best practice) patterns.

Facilitates HIVE-2476

@2uasimojo
Copy link
Member Author

NB: Currently stacked on #2251

@openshift-ci openshift-ci bot requested review from lleshchi and suhanime April 1, 2024 22:18
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 2uasimojo

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 1, 2024
@2uasimojo
Copy link
Member Author

2uasimojo commented Apr 1, 2024

/assign @suhanime

(Just look at the last commit please -- @lleshchi is reviewing the rest via #2251.)
[Later] Rebased; just the one commit to look at now.

@codecov
Copy link

codecov bot commented Apr 2, 2024

Codecov Report

Attention: Patch coverage is 94.20290% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 58.58%. Comparing base (5f27f3c) to head (9a5473a).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2252      +/-   ##
==========================================
+ Coverage   58.47%   58.58%   +0.11%     
==========================================
  Files         182      182              
  Lines       25719    25775      +56     
==========================================
+ Hits        15038    15101      +63     
+ Misses       9411     9402       -9     
- Partials     1270     1272       +2     
Files Coverage Δ
pkg/test/machinepool/machinepool.go 94.17% <94.20%> (+21.83%) ⬆️

@2uasimojo
Copy link
Member Author

/test e2e-gcp

@2uasimojo
Copy link
Member Author

/test e2e-gcp

In preparation for expanding OpenStack-specific MachinePool unit tests,
refactor the helper funcs in the existing suite to use the MachinePool
"Builder" pattern with "Options". For example, we change this:

```go
machinePool: func() *hivev1.MachinePool {
        mp := testMachinePoolWithoutLabelsTaints()
        mp.Spec.Labels = make(map[string]string)
        mp.Spec.Labels["test-label"] = "test-value"
        return mp
}(),
```

to:

```go
machinePool: testMachinePoolWithoutLabelsTaints(
        testmp.WithLabels(map[string]string{
                "test-label": "test-value",
        }),
),
```

This makes the test code slightly tighter and more readable, and brings
the suite more in line with our usual (or at least, best practice)
patterns.

Facilitates HIVE-2476
@2uasimojo 2uasimojo force-pushed the HIVE-2476/refactor-mp-ut-opts branch from a351461 to 9a5473a Compare April 2, 2024 22:15
@suhanime
Copy link
Contributor

suhanime commented Apr 4, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 4, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit fb27114 into openshift:master Apr 4, 2024
@2uasimojo 2uasimojo deleted the HIVE-2476/refactor-mp-ut-opts branch April 4, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants