Repository navigation
Add error message for importing branch protection - #721
Merged
jcudit merged 3 commits intoMar 24, 2021
Merged
Conversation
Add a useful error message when a user attempts to import a branch protection rule that does not exist. Before: Error: nil entry in ImportState results. This is always a bug with the resource that is being imported. Please report this as a bug to Terraform. After: Error: Could not find a branch protection rule with the pattern 'master'.
jcudit
approved these changes
Mar 16, 2021
Contributor
|
This looks like it'll fix our issue and tests are passing locally for existing functionality. @tibbes happy to merge as-is but will also leave some guidance on a possible approach to testing if you'd like to follow up there:
testCase := func(t *testing.T, mode string) {
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessMode(t, mode) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: check,
},
{
ResourceName: "github_organization_webhook.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
} |
Contributor
Author
|
@jcudit, thanks for pointing out |
Contributor
Author
|
(sorry—accidental close of PR) |
jcudit
approved these changes
Mar 22, 2021
kfcampbell
pushed a commit
to kfcampbell/terraform-provider-github
that referenced
this pull request
Jul 26, 2022
* Add error message for importing branch protection Add a useful error message when a user attempts to import a branch protection rule that does not exist. Before: Error: nil entry in ImportState results. This is always a bug with the resource that is being imported. Please report this as a bug to Terraform. After: Error: Could not find a branch protection rule with the pattern 'master'. * Test error message for importing branch protection * Simplify code in branch protection import
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@bateller reported (as a follow-up on #671) that the import function for
github_branch_protectiondoesn't give a nice error message if the resource doesn't exist on GitHub.This pull request changes the message to:
The trouble is, I don't know how to add an idiomatic test for this change. Any advice would be much appreciated.