Pulling out the hardcoded test user

This commit is contained in:
Jacob Severson 2016-03-18 21:55:33 -05:00
parent 111a59c634
commit b1e7065878
3 changed files with 50 additions and 43 deletions

View File

@ -35,4 +35,7 @@ func testAccPreCheck(t *testing.T) {
if v := os.Getenv("GITHUB_ORGANIZATION"); v == "" { if v := os.Getenv("GITHUB_ORGANIZATION"); v == "" {
t.Fatal("GITHUB_ORGANIZATION must be set for acceptance tests") t.Fatal("GITHUB_ORGANIZATION must be set for acceptance tests")
} }
if v := os.Getenv("GITHUB_TEST_USER"); v == "" {
t.Fatal("GITHUB_TEST_USER must be set for acceptance tests")
}
} }

View File

@ -7,11 +7,20 @@ import (
"github.com/google/go-github/github" "github.com/google/go-github/github"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"os"
) )
func TestAccGithubMembership_basic(t *testing.T) { func TestAccGithubMembership_basic(t *testing.T) {
var membership github.Membership var membership github.Membership
testUser := os.Getenv("GITHUB_TEST_USER")
testAccGithubMembershipConfig := fmt.Sprintf(`
resource "github_membership" "test_org_membership" {
username = "%s"
role = "member"
}
`, testUser)
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
@ -104,10 +113,3 @@ func testAccCheckGithubMembershipRoleState(n string, membership *github.Membersh
return nil return nil
} }
} }
const testAccGithubMembershipConfig = `
resource "github_membership" "test_org_membership" {
username = "TerraformDummyUser"
role = "member"
}
`

View File

@ -7,11 +7,49 @@ import (
"github.com/google/go-github/github" "github.com/google/go-github/github"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"os"
) )
func TestAccGithubTeamMembership_basic(t *testing.T) { func TestAccGithubTeamMembership_basic(t *testing.T) {
var membership github.Membership var membership github.Membership
testUser := os.Getenv("GITHUB_TEST_USER")
testAccGithubTeamMembershipConfig := fmt.Sprintf(`
resource "github_membership" "test_org_membership" {
username = "%s"
role = "member"
}
resource "github_team" "test_team" {
name = "foo"
description = "Terraform acc test group"
}
resource "github_team_membership" "test_team_membership" {
team_id = "${github_team.test_team.id}"
username = "%s"
role = "member"
}
`, testUser, testUser)
testAccGithubTeamMembershipUpdateConfig := fmt.Sprintf(`
resource "github_membership" "test_org_membership" {
username = "%s"
role = "member"
}
resource "github_team" "test_team" {
name = "foo"
description = "Terraform acc test group"
}
resource "github_team_membership" "test_team_membership" {
team_id = "${github_team.test_team.id}"
username = "%s"
role = "maintainer"
}
`, testUser, testUser)
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
@ -114,39 +152,3 @@ func testAccCheckGithubTeamMembershipRoleState(n, expected string, membership *g
return nil return nil
} }
} }
const testAccGithubTeamMembershipConfig = `
resource "github_membership" "test_org_membership" {
username = "TerraformDummyUser"
role = "member"
}
resource "github_team" "test_team" {
name = "foo"
description = "Terraform acc test group"
}
resource "github_team_membership" "test_team_membership" {
team_id = "${github_team.test_team.id}"
username = "TerraformDummyUser"
role = "member"
}
`
const testAccGithubTeamMembershipUpdateConfig = `
resource "github_membership" "test_org_membership" {
username = "TerraformDummyUser"
role = "member"
}
resource "github_team" "test_team" {
name = "foo"
description = "Terraform acc test group"
}
resource "github_team_membership" "test_team_membership" {
team_id = "${github_team.test_team.id}"
username = "TerraformDummyUser"
role = "maintainer"
}
`