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

bugfix: pass annotation value to strconv.ParseBool #2894

Merged
merged 2 commits into from Apr 24, 2020

Conversation

anfanycw
Copy link
Contributor

Description of the change:
helm: pass force to strconv.ParseBool() instead of helmUpgradeForceAnnotation

Motivation for the change:
Fixes issue where helm.operator-sdk/upgrade-force annotation value is not being respected

Closes #2884

evalutes correct variable that holds the annotation value instead of cost `helmUpgradeForceAnnotation`
@jberkhahn
Copy link
Contributor

looks like the travis build itself had an duplicate job id?
/retest

Copy link
Contributor

@camilamacedo86 camilamacedo86 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

Really great 👍 With the tests. It is terrific.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 23, 2020
}

for _, test := range tests {
assert.Equal(t, test.expectedVal, hasHelmUpgradeForceAnnotation(annotations(test.input)), test.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would not be required used assert in this case. We could do something such as follows but I am ok with 👍

Suggested change
assert.Equal(t, test.expectedVal, hasHelmUpgradeForceAnnotation(annotations(test.input)), test.name)
got := hasHelmUpgradeForceAnnotation(annotations(test.input))
if test.expectedVal != got {
t.Fatalf("For hasHelmUpgradeForceAnnotation expected the value %v and got %v", test.expectedVal, got)
}

Copy link
Member

Choose a reason for hiding this comment

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

Is assert bad? I much prefer asserts

Copy link
Contributor

Choose a reason for hiding this comment

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

I just make the comment to share, however, as I said above, I am ok 👍 with move forward here. Tests are great always and it is just a nit really.

Please, feel free to merge this one if you are also ok with @jmrodri .

Just to share, regards your question

Is assert bad? I much prefer asserts

In the past, I advocate in favour of the asserts usage as well because I just was not adapted to the Testing style. However, after while I changed my mind. According to the Golang authors they have reasons to do NOT added it deliberately in the language.

See in the GoDocs:

And then following a summary of the cons:

  • Tests can feel like they're written in a different language (RSpec/Mocha for instance)
  • Errors can be cryptic "assert: 0 == 1"
  • Pages of stack traces can be generated
  • Tests stop executing after the first assert fails - masking patterns of failure

PS.: In SDK, we have been using the asserts mainly for the scaffolds tests.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer asserts and think that some of the opinions in the go FAQ are just that, opinions.

Unless we as a community are extremely diligent about test style using the standard testing library:

  1. We end up with a total hodge podge of not-so-great tests.
  2. The failure messages are inconsistent at best and not helpful at worst.
  3. Writing tests take longer and more lines of code, which means time not spent adding more features or fixing more bugs AND it is more to review, understand, and maintain.

Regardless, I don't want to start a flame war 😆. We're using github.com/stretchr/testify in many (perhaps most) of our tests already, and I think consistency is the most important thing here.

}
}

func annotations(m map[string]interface{}) *unstructured.Unstructured {
Copy link
Contributor

Choose a reason for hiding this comment

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

here could be a name that clarifies better such as addMockAnnotation but I am ok with as well 👍

Co-Authored-By: Camila Macedo <cmacedo@redhat.com>
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 24, 2020
@camilamacedo86 camilamacedo86 added the lgtm Indicates that a PR is ready to be merged. label Apr 24, 2020
@joelanford joelanford merged commit 5b9a719 into operator-framework:master Apr 24, 2020
@estroz
Copy link
Member

estroz commented May 13, 2020

/cherry-pick v0.17.x

@openshift-cherrypick-robot

@estroz: new pull request created: #3027

In response to this:

/cherry-pick v0.17.x

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

estroz pushed a commit that referenced this pull request May 14, 2020
Co-Authored-By: Camila Macedo <cmacedo@redhat.com>

Cherry pick of #2894
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

helm.operator-sdk/upgrade-force annotation value is not actually parsed
8 participants