Closed david-ortiz-saez closed 6 months ago
@jdamata kindly review :)
@david-ortiz-saez Can you add one or more unit tests to demonstrate that you have fixed the problem you have reported? Automated tests are a good way to ensure that the expected outcome is indeed the actual outcome :)
Also there is no v0.62.3 :}
hi @freeranger, thanks for pointing out these errors. I've fixed them.
Regarding the unit tests, this method is already covered with tests.
We have built the plugin and run the terraform plan that was failing and now it doesn't
hi @david-ortiz-saez
Regarding the unit tests, this method is already covered with tests.
Since those tests pass with or without your change, that suggests that the use case is not covered by the tests - hence I am suggesting you add additional tests to cover this and demonstrate that the code works in all cases. thanks
Hi @freeranger! I've added a test case where we take the language from the sonarqube project itself, same as my changes are doing. Hope that helps
hi @freeranger, @jdamata. After further reviewing it I've reached the conclusion that sadly we cannot create a test for this use case.
This PR is fixing the provider to work with the already existing sonarqube_qualityprofile_project_association
.
Since v0.16.3 each new sonarqube_qualityprofile_project_association
that is created will have an id in terraform state like this one:
"Quality_Profile/Project/Language".
So when we try to access idSlice[2] there is no problem.
However, for those sonarqube_qualityprofile_project_association
that were created using provider version v0.16.2
or lower, their id in terraform state is only "Quality_Profile/Project" without language, and trying to access idSlice[2]
make the program crash.
As this id
is automatically created inside the code only when a new sonarqube_qualityprofile_project_association
is created, we have no way to simulate these already existing resources with language in the id over tests. Because each new resource that we try to create will already have the id
in the new format.
To test that this pr is working we have built the provider locally and use it inside our terraform code.
WHAT
This is fixing ISSUE-216.
In v0.16.3 release this was changed.
As a consequence, when new
qualityprofile_project_associations
are created, it will provideidSlice[2]
with the language of the qualityProfile.However, for qualityProfileAssociations that were created using this module before that association, the
idSlice
lenght is only 2, beingidSlice[0]
the name andidSlice[1]
the key. As a consequence, when we try to upgrade from v0.16.2 to v0.16.3 we're getting an error:This Pr is fixing the issue, if idSlice[2] doesn't exist, it will use the Get method to populate the language