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

Make data_github_repository work with non-existing repositories #1031

Merged
merged 4 commits into from
Mar 3, 2022
Merged

Make data_github_repository work with non-existing repositories #1031

merged 4 commits into from
Mar 3, 2022

Conversation

tobiassjosten
Copy link
Contributor

Fixes #933 – github_repository needs to not fail if repository doesn't exist.

This is my first stab at working with a Terraform provider, so bear with me. :)

I began by updating the tests and even with this new condition and no changes to the code, they still worked. So I'm not sure how useful they actually are. As for the implementation itself, I referenced c240bcc for the logic but since I don't trust the tests too much I'm not entirely sure how to best verify the change. Please advice!

Copy link
Contributor

@jcudit jcudit left a comment

Choose a reason for hiding this comment

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

Looks close!

As for testing, I think it makes sense to delete the TestAccGithubRepositoryDataSource/raises_expected_errors_when_querying_for_a_repository test given the nature of this change. Feel free to 🔥 it on your next pass. All other tests in that file were passing for me.

github/data_source_github_repository.go Outdated Show resolved Hide resolved
@jcudit jcudit modified the milestones: v4.19.2, v4.20.0 Jan 21, 2022
@tobiassjosten
Copy link
Contributor Author

Thank you so much for the feedback, @jcudit! I'll have another stab at it next week. 👍

Although, I think I tweaked that specific test so as to verify that the data resource works with non-existent repos. Perhaps it should be renamed? Or do you not see a big need for it in the test suite?

Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

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

This change might be worthy of a new major version; it feels backwards-incompatible although it's more permissive.

@tobiassjosten I agree, the tests are somewhat confusing and not always reliable. I've found I get the most confidence from writing Terraform configuration and using the instructions in our Contributing.md to validate that the changes made are working.

github/data_source_github_repository_test.go Outdated Show resolved Hide resolved
github/data_source_github_repository_test.go Outdated Show resolved Hide resolved
github/data_source_github_repository.go Outdated Show resolved Hide resolved
github/data_source_github_repository_test.go Outdated Show resolved Hide resolved
@tobiassjosten
Copy link
Contributor Author

I couldn't quite figure out what to test with this change and with both @jcudit and @kfcampbell recommending deleting the one affected test, that's what I did. I'll admit I still haven't run through the testing steps in CONTRIBUTING.md so that's what I'll do next. The code should be done, though.

@tobiassjosten
Copy link
Contributor Author

Acceptance tests are working fine and I've rebased and updated the dependencies to be in line with the evolving main branch. Are we good to merge? :)

Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

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

Yep I think this is good to go, thank you!

@kfcampbell kfcampbell modified the milestones: v4.20.0, v4.20.1 Mar 3, 2022
@kfcampbell kfcampbell merged commit cae33d2 into integrations:main Mar 3, 2022
@tobiassjosten tobiassjosten deleted the non-existing-repo-data branch March 3, 2022 21:43
kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
…grations#1031)

* Make data_github_repository work with non-existing repositories

* Improve 404 logging

* Remove obsolete test

* Update dependency
kazaker pushed a commit to auto1-oss/terraform-provider-github that referenced this pull request Dec 28, 2022
…grations#1031)

* Make data_github_repository work with non-existing repositories

* Improve 404 logging

* Remove obsolete test

* Update dependency
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.

github_repository needs to not fail if repository doesn't exist
3 participants