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

Fix failing unit test for parseImportID #1426

Merged
merged 2 commits into from Sep 28, 2021
Merged

Conversation

jrhouston
Copy link
Contributor

@jrhouston jrhouston commented Sep 27, 2021

Description

This unit test was failing because parseImportID will set namespace to default if it's not present. We would have to check if the kind was a namespaced resource to figure out if we should omit it or not. AFAIK namespace should just get ignored for non-namespaced resources so this should be fine for now.

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

Release Note

Release note for CHANGELOG:

NONE

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

@@ -50,15 +50,15 @@ func TestParseImportID(t *testing.T) {
t.Fatal(actualErr.Error())
}
if expected.GVK != actualGvk {
t.Log("GVK (actual / wanted):", actualGvk, expected.GVK)
t.Logf("GVK did not match. actual: %q expected: %q.", actualGvk, expected.GVK)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took me a minute to figure out which case was actually failing so I made this a bit more readable.

@keithmattix
Copy link
Contributor

I actually took the opposite approach in my PR because I would think cluster scoped resources (like ClusterRole, or MutatingWebhookConfiguration) wouldn't need to carry around a namespace in their TF ID. If I'm wrong about that, I'm definitely open to modifying my PR

Copy link
Member

@alexsomesan alexsomesan left a comment

Choose a reason for hiding this comment

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

LGTM! Nice improvement!

@jrhouston
Copy link
Contributor Author

I actually took the opposite approach in my PR because I would think cluster scoped resources (like ClusterRole, or MutatingWebhookConfiguration) wouldn't need to carry around a namespace in their TF ID. If I'm wrong about that, I'm definitely open to modifying my PR

Thanks for commenting @keithmattix – I think it has to be this way around, otherwise people will always have to specify a namespace= in the import ID even if it is default. We want the function to set the namespace to default if it's not present. Ideally the function would check if the kind is namespaced or not. I've added a FIXME to tidy this up later, for the moment I just want to get the tests passing in main again.

@jrhouston jrhouston merged commit 09fa4ea into main Sep 28, 2021
@jrhouston jrhouston deleted the fix-import-id-unit-test branch September 28, 2021 15:51
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants