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 project setting creation #202

Merged
merged 19 commits into from
Dec 18, 2023

Conversation

pnag90
Copy link
Contributor

@pnag90 pnag90 commented Sep 21, 2023

  • Creating new project setting was failing do to missmatch between remote inherit settings
  • Added condition to set new settings associated with a project

@pnag90 pnag90 changed the title Bugfix: project setting creation Fix project setting creation Sep 21, 2023
@jdamata jdamata marked this pull request as draft October 13, 2023 19:13
@jdamata
Copy link
Owner

jdamata commented Oct 13, 2023

@pnag90 I converted this to a draft PR. You should still get build results on commits. When its working and ready for review, set it back to ready for review :)

@pnag90 pnag90 marked this pull request as ready for review October 15, 2023 20:22
@tbutler-qontigo
Copy link
Contributor

I have added a few comments but obviously it is up to @jdamata if he agrees with them or not.
Other opinions are available :)

}
return true
} else if a["field_values"] != nil {
if a["field_values"] != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

What are we gaining by refactoring in this way?
I would suggest that it is far far far more likely that a setting is single-valued rather than multi-valued so shouldn't we check that first as the most likely case?
Aside from it being a micro-optimisation, it makes more sense IMO to handle the most common case as early as possible, which is what the original code was doing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What was happening is that terraform loads the value from the setting property from the resource.
But even the field value was not being set in the tf script, the value at this point is an empty string instead of being null.

Copy link
Contributor

Choose a reason for hiding this comment

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

so...couldn't you check if a["value"] != nil && a["value"] != "" first?
You would possibly also need to account for them all being empty - because settings are cleared out vs "is it value or values or field_values" that has a value - maybe none of them do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I though about that, but I think that we cannot guarantee that no one will set the value as "" for a specific setting

@tbutler-qontigo
Copy link
Contributor

@pnag90 One other comment - since all the tests were passing before and you have not added any new tests then this suggests that the condition you are trying to fix (Which is unclear to me TBH) is not covered by the tests so....a) how does anyone know you fixed it at all? and b) It seems like it would make sense to add one or more tests to cover the scenarion to prove that it is fixed - and if they are run against the current code, they would fail.

Having green tests before your change and and the same tests still green afterwards suggests that either your change does nothing or that the existing tests are insufficient. I suspect the latter, in which case they are still insufficient!

@pnag90
Copy link
Contributor Author

pnag90 commented Oct 16, 2023

@pnag90 One other comment - since all the tests were passing before and you have not added any new tests then this suggests that the condition you are trying to fix (Which is unclear to me TBH) is not covered by the tests so....a) how does anyone know you fixed it at all? and b) It seems like it would make sense to add one or more tests to cover the scenarion to prove that it is fixed - and if they are run against the current code, they would fail.

Having green tests before your change and and the same tests still green afterwards suggests that either your change does nothing or that the existing tests are insufficient. I suspect the latter, in which case they are still insufficient!

The tests were working for specific dummy examples of settings.
When I tried to use the provider in a different project, start to fail with "real" use case settings.

Update branch with master release (v0.16.9)
@jdamata
Copy link
Owner

jdamata commented Dec 18, 2023

@pnag90 One other comment - since all the tests were passing before and you have not added any new tests then this suggests that the condition you are trying to fix (Which is unclear to me TBH) is not covered by the tests so....a) how does anyone know you fixed it at all? and b) It seems like it would make sense to add one or more tests to cover the scenarion to prove that it is fixed - and if they are run against the current code, they would fail.
Having green tests before your change and and the same tests still green afterwards suggests that either your change does nothing or that the existing tests are insufficient. I suspect the latter, in which case they are still insufficient!

The tests were working for specific dummy examples of settings. When I tried to use the provider in a different project, start to fail with "real" use case settings.

Yes, I think what @tbutler-qontigo is rightly mentioning is that we would like to have those "real" use case settings that were failing for you to be added in. It would improve our test coverage posture and also confirm that your changes work for the issues you had. Of course sanitize any data you are using in your project

Also apology for the super late review. I reviewed this part way a long time ago and never came back to finish reading up. Thanks @tbutler-qontigo for reviewing this :)

@pnag90 pnag90 marked this pull request as draft December 18, 2023 08:34
@pnag90 pnag90 marked this pull request as ready for review December 18, 2023 10:03
@pnag90
Copy link
Contributor Author

pnag90 commented Dec 18, 2023

Added tests for covering edition of a property setting

@pnag90 pnag90 marked this pull request as draft December 18, 2023 10:19
@pnag90 pnag90 marked this pull request as ready for review December 18, 2023 14:40
@jdamata jdamata merged commit 348f57e into jdamata:master Dec 18, 2023
11 checks passed
@pnag90 pnag90 deleted the feature/fix-setting-creation branch December 27, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants