forked from claranet/terraform-provider-clouddeploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TER-233: Add tests for provider and ghost app resource, add make test…
… recipes and add test packages to vendor
- Loading branch information
Jordan Caussat
authored and
Jordan Caussat
committed
Mar 19, 2018
1 parent
bf4b9bd
commit c2dfba7
Showing
73 changed files
with
21,703 additions
and
8 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,43 @@ | ||
package ghost | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
var testAccProviders map[string]terraform.ResourceProvider | ||
var testAccProvider *schema.Provider | ||
|
||
func init() { | ||
testAccProvider = Provider().(*schema.Provider) | ||
testAccProviders = map[string]terraform.ResourceProvider{ | ||
"ghost": testAccProvider, | ||
} | ||
} | ||
|
||
func TestProvider(t *testing.T) { | ||
if err := Provider().(*schema.Provider).InternalValidate(); err != nil { | ||
t.Fatalf("err: %s", err) | ||
} | ||
} | ||
|
||
func TestProviderImpl(t *testing.T) { | ||
var _ terraform.ResourceProvider = Provider() | ||
} | ||
|
||
func testAccPreCheck(t *testing.T) { | ||
if v := os.Getenv("GHOST_USER"); v == "" { | ||
t.Fatal("GHOST_USER must be set for acceptance tests") | ||
} | ||
|
||
if v := os.Getenv("GHOST_PASSWORD"); v == "" { | ||
t.Fatal("GHOST_USER must be set for acceptance tests") | ||
} | ||
|
||
if v := os.Getenv("GHOST_ENDPOINT"); v == "" { | ||
t.Fatal("GHOST_USER must be set for acceptance tests") | ||
} | ||
} |
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,81 @@ | ||
package ghost | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestGhostAppBasic(t *testing.T) { | ||
resourceName := "ghost_app.test" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testGhostAppConfig(resourceName), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr(resourceName, "name", "wordpress"), | ||
resource.TestCheckResourceAttrSet("env", "dv"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testGhostAppConfig(name string) string { | ||
return fmt.Sprintf(` | ||
resource "ghost_app" "test" { | ||
name = "%s" | ||
env = "dev" | ||
role = "webfront" | ||
region = "eu-west-1" | ||
instance_type = "t2.micro" | ||
vpc_id = "vpc-3f1eb65a" | ||
log_notifications = [ | ||
"[email protected]", | ||
] | ||
build_infos = { | ||
subnet_id = "subnet-a7e849fe" | ||
ssh_username = "admin" | ||
source_ami = "ami-03ce4474" | ||
} | ||
environment_infos = { | ||
instance_profile = "iam.ec2.demo" | ||
key_name = "ghost-demo" | ||
root_block_device = {} | ||
optional_volumes = [] | ||
subnet_ids = ["subnet-a7e849fe"] | ||
security_groups = ["sg-6814f60c"] | ||
} | ||
autoscale = { | ||
name = "" | ||
} | ||
module = { | ||
name = "symfony2" | ||
pre_deploy = "ZXhpdCAx" | ||
path = "/var/www" | ||
scope = "code" | ||
git_repo = "https://github.com/KnpLabs/KnpIpsum.git" | ||
} | ||
feature = { | ||
version = "5.4" | ||
name = "php5" | ||
} | ||
feature = { | ||
version = "2.2" | ||
name = "apache2" | ||
} | ||
} | ||
`, name) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
145 changes: 145 additions & 0 deletions
145
vendor/github.com/davecgh/go-spew/spew/bypass.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.