Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ginkgolinter and fix findings #225

Merged
merged 1 commit into from
Feb 15, 2023

Conversation

nunnatsa
Copy link
Contributor

In addition to the ginkgo linter findings, replace this pattern:

err = funcRetErr()
Expect(err).ToNot(HaveOccurred())

With the more readable version of:

Expect(funcRetErr()).To(Succeed())

Improve some Eventually usages by using the Gomega parameter instead of returning error, to get cleaner test code.

Also, replaced some deprecation methods.

Signed-off-by: Nahshon Unna-Tsameret nunnatsa@redhat.com

What this PR does / why we need it:

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Release notes:

None

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 14, 2023
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 14, 2023
@coveralls
Copy link

coveralls commented Feb 14, 2023

Pull Request Test Coverage Report for Build 4181316724

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 52.655%

Totals Coverage Status
Change from base Build 4069808194: 0.0%
Covered Lines: 952
Relevant Lines: 1808

💛 - Coveralls

@nunnatsa
Copy link
Contributor Author

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Feb 14, 2023
@nunnatsa nunnatsa force-pushed the improve-linter branch 5 times, most recently from eb97cb1 to 7680733 Compare February 14, 2023 15:04
Comment on lines -115 to 127
Eventually(func() error {
Eventually(func(g Gomega) {
machineList := &infrav1.KubevirtMachineList{}
err := k8sclient.List(context.Background(), machineList, client.InNamespace(namespace))
if err != nil {
return err
}
g.Expect(
k8sclient.List(context.Background(), machineList, client.InNamespace(namespace)),
).To(Succeed())

if len(machineList.Items) == 0 {
return fmt.Errorf("expecting a non-empty list of machines")
}
g.Expect(machineList.Items).ToNot(BeEmpty(), "expecting a non-empty list of machines")

for _, machine := range machineList.Items {
if !conditions.IsTrue(&machine, infrav1.BootstrapExecSucceededCondition) {
return fmt.Errorf("still waiting on a kubevirt machine with bootstrap succeeded condition")
}
g.Expect(conditions.IsTrue(&machine, infrav1.BootstrapExecSucceededCondition)).To(
BeTrue(),
"still waiting on a kubevirt machine with bootstrap succeeded condition",
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We're waiting to "eventually" have this loop pass without errors. By introducing the g.Expect logic in this loop, will the eventually loop still be eventually consistent once no errors are encountered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

oh perfect. okay

@davidvossel
Copy link
Contributor

/retest

In addition to the ginkgo linter findings, replace this pattern:
```go
err = funcRetErr()
Expect(err).ToNot(HaveOccurred())
```

With the more readable version of:
```go
Expect(funcRetErr()).To(Succeed())
```

Improve some Eventually usages by using the Gomega parameter instead of returning error, to get cleaner test code.

Also, replaced some deprecation methods.

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
Copy link
Contributor

@davidvossel davidvossel left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 15, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidvossel, nunnatsa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [davidvossel,nunnatsa]

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

@k8s-ci-robot k8s-ci-robot merged commit 1c6ec37 into kubernetes-sigs:main Feb 15, 2023
@nunnatsa nunnatsa deleted the improve-linter branch February 15, 2023 17:48
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants