-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autogenerate google_sourcerepo_repository (#2797)
- Loading branch information
1 parent
6b29503
commit 181dafe
Showing
6 changed files
with
284 additions
and
125 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// This file is automatically generated by Magic Modules and manual | ||
// changes will be clobbered when the file is regenerated. | ||
// | ||
// Please read more about how to change this file in | ||
// .github/CONTRIBUTING.md. | ||
// | ||
// ---------------------------------------------------------------------------- | ||
|
||
package google | ||
|
||
import "github.com/hashicorp/terraform/helper/schema" | ||
|
||
var GeneratedSourcerepoResourcesMap = map[string]*schema.Resource{ | ||
"google_sourcerepo_repository": resourceSourcerepoRepository(), | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// This file is automatically generated by Magic Modules and manual | ||
// changes will be clobbered when the file is regenerated. | ||
// | ||
// Please read more about how to change this file in | ||
// .github/CONTRIBUTING.md. | ||
// | ||
// ---------------------------------------------------------------------------- | ||
|
||
package google | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
func TestAccSourcerepoRepository_sourcerepoRepositoryBasicExample(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(10), | ||
} | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckSourcerepoRepositoryDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccSourcerepoRepository_sourcerepoRepositoryBasicExample(context), | ||
}, | ||
{ | ||
ResourceName: "google_sourcerepo_repository.my-repo", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccSourcerepoRepository_sourcerepoRepositoryBasicExample(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_sourcerepo_repository" "my-repo" { | ||
name = "my-repository-%{random_suffix}" | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccCheckSourcerepoRepositoryDestroy(s *terraform.State) error { | ||
for name, rs := range s.RootModule().Resources { | ||
if rs.Type != "google_sourcerepo_repository" { | ||
continue | ||
} | ||
if strings.HasPrefix(name, "data.") { | ||
continue | ||
} | ||
|
||
config := testAccProvider.Meta().(*Config) | ||
|
||
url, err := replaceVarsForTest(rs, "https://sourcerepo.googleapis.com/v1/projects/{{project}}/repos/{{name}}") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = sendRequest(config, "GET", url, nil) | ||
if err == nil { | ||
return fmt.Errorf("SourcerepoRepository still exists at %s", url) | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.