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

Fixes parent team removal, fixes the teams data source tests, adds tests for the parent team fix #1979

Merged
merged 5 commits into from
Oct 25, 2023

Conversation

scott-doyland-burrows
Copy link
Contributor

@scott-doyland-burrows scott-doyland-burrows commented Oct 25, 2023

Resolves #1668
Resolves #1975

I have closed #1976 (which I initially setup) as this also resolves #1975 but is no longer needed as this PR will now fix it.


Before the change?

#1668
Parent teams were created in terraform. However if a team was removed from the parent team then the statefile was updated, but the team still remained under a parent team in GitHub.

Also, if a team was removed from under a parent team in GitHub but still was defined in terraform, then terraform would not show a diff.

Overall, nested teams were not correctly managed by Terraform.

#1975
Before the change there was a failure reported in a test in the data_source_github_team_test.go file. The reason is the terraform data resource in the queries an existing team with connected repositories test block is only waiting on the github_team resource, and the data resource actually needs to wait on the github_team_repository resource.

Running this test:
TF_LOG=WARN TF_ACC=1 go test -v ./... -run ^TestAccGithubTeamDataSource
would result in a failure:

    testing.go:705: Step 0 error: Check failed: 3 errors occurred:
        	 Check 2/4 error: data.github_team.test: Attribute 'repositories_detailed.#' expected "1", got "0"
        	 Check 3/4 error: data.github_team.test: Attribute "repositories_detailed.0.repo_id" not set, but "repo_id" is set in github_repository.test as "708930695"
        	 Check 4/4 error: data.github_team.test: Attribute "repositories_detailed.0.role_name" not set, but "permission" is set in github_team_repository.test as "admin"

However, if using TF_LOG=DEBUG it would finish successfully - I believe this is just a timing issue. TF_LOG=DEBUG takes longer to run each resource, so by the time the data resource is actioned, the previous resources have all (just by chance) also completed.

It appears that the test for TestAccGithubTeamDataSource was defined incorrectly. I have refactored to bring the test in-line with how other tests are defined and this appears to have resolved the issue.

Formatting

The .tf files are now formatted correctly.

After the change?

Parent teams are correctly managed by Terraform. Tests have been defined and pass.

The data source tests for teams work.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@scott-doyland-burrows scott-doyland-burrows changed the title Fixes parent team removal, fixes tests inthe Fixes parent team removal, fixes the teams data source tests, adds tests for the parent team fix Oct 25, 2023
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 is great! Thank you for the thoughtful PR. All updated integration tests are passing for me as well.

@kfcampbell kfcampbell merged commit fbcad03 into integrations:main Oct 25, 2023
4 checks passed
@scott-doyland-burrows scott-doyland-burrows deleted the fix/parent-teams branch October 26, 2023 08:11
avidspartan1 pushed a commit to avidspartan1/terraform-provider-github that referenced this pull request Feb 5, 2024
…sts for the parent team fix (integrations#1979)

* fixes an issue with the provider checks in data_source_github_team_test

* formatted code with gofmt to fix linting

* add blank line to end of providers.tf file for formatting

* fix parent teams config so the parent team in GitHub matches that of the terraform config

* sets default for parent team to empty string and adds in tests
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.

[BUG]: Odd behaviour when running provider tests [FEAT]: Remove parent team when parent_team_id == 0
2 participants