-
Notifications
You must be signed in to change notification settings - Fork 763
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
Add error message for importing branch protection #721
Add error message for importing branch protection #721
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'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Also this closes #597
Disregard, we'll need another PR to fix importing by branch_id
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,
},
},
})
} |
@jcudit, thanks for pointing out |
(sorry—accidental close of PR) |
* 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
@bateller reported (as a follow-up on #671) that the import function for
github_branch_protection
doesn'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.