-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from docker/fix-tests
Fix tests
- Loading branch information
Showing
8 changed files
with
133 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Ignore Terraform state files | ||
*.tfstate | ||
*.tfstate.backup |
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
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
File renamed without changes.
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
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,70 @@ | ||
package provider | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
) | ||
|
||
func TestRepositoryResource(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testRepositoryResourceConfig(), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("dockerhub_repository.test", "id"), | ||
resource.TestCheckResourceAttr("dockerhub_repository.test", "name", "example-repo"), | ||
resource.TestCheckResourceAttr("dockerhub_repository.test", "namespace", os.Getenv("DOCKERHUB_USERNAME")), | ||
resource.TestCheckResourceAttr("dockerhub_repository.test", "description", "Example repository"), | ||
resource.TestCheckResourceAttr("dockerhub_repository.test", "full_description", ""), | ||
resource.TestCheckResourceAttr("dockerhub_repository.test", "private", "false"), | ||
), | ||
}, | ||
{ | ||
Config: testRepositoryResourceConfigUpdated(), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("dockerhub_repository.test", "description", "Updated example repository"), | ||
resource.TestCheckResourceAttr("dockerhub_repository.test", "full_description", ""), | ||
resource.TestCheckResourceAttr("dockerhub_repository.test", "private", "true"), | ||
), | ||
}, | ||
{ | ||
ResourceName: "dockerhub_repository.test", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIdentifierAttribute: "id", | ||
ImportStateIdFunc: func(state *terraform.State) (string, error) { | ||
return state.RootModule().Resources["dockerhub_repository.test"].Primary.Attributes["id"], nil | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testRepositoryResourceConfig() string { | ||
return ` | ||
resource "dockerhub_repository" "test" { | ||
name = "example-repo" | ||
namespace = "` + os.Getenv("DOCKERHUB_USERNAME") + `" | ||
description = "Example repository" | ||
full_description = "" | ||
private = false | ||
} | ||
` | ||
} | ||
|
||
func testRepositoryResourceConfigUpdated() string { | ||
return ` | ||
resource "dockerhub_repository" "test" { | ||
name = "example-repo" | ||
namespace = "` + os.Getenv("DOCKERHUB_USERNAME") + `" | ||
description = "Updated example repository" | ||
full_description = "" | ||
private = true | ||
} | ||
` | ||
} |