-
Notifications
You must be signed in to change notification settings - Fork 1
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 #3 from COzero/feature/pipeline-create
r/pipeline
- Loading branch information
Showing
14 changed files
with
783 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,31 +1,53 @@ | ||
package buildkite | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
// We need a pipeline resource so that this can be tested properly | ||
const testAccDataSourcePipelineRead = ` | ||
data buildkite_pipeline "test" { | ||
name = "Stu's Great Showcase Pipeline" | ||
organization = "cozero" | ||
} | ||
` | ||
func TestAccDataSourcePipeline(t *testing.T) { | ||
rStr := acctest.RandString(6) | ||
|
||
func TestAccDataSourcePipelineRead(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: testAccDataSourcePipelineRead, | ||
Config: testAccDataSourcePipeline(rStr), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("data.buildkite_pipeline.test", "web_url"), | ||
resource.TestCheckResourceAttr( | ||
"data.buildkite_pipeline.test", | ||
"name", | ||
fmt.Sprintf("Acceptance test :terraform: %s", rStr), | ||
), | ||
), | ||
}, | ||
}, | ||
}) | ||
return | ||
} | ||
|
||
func testAccDataSourcePipeline(rStr string) string { | ||
return fmt.Sprintf(` | ||
resource buildkite_pipeline "test" { | ||
name = "Acceptance test :terraform: %s" | ||
organization = "cozero" | ||
description = "Generated via acceptance tests - please delete if left dangling" | ||
repository = "[email protected]:COzero/terraform-provider-buildkite.git" | ||
steps = [{ | ||
type = "script" | ||
name = "Hi!" | ||
command = "echo \"Hello world\"" | ||
}] | ||
} | ||
data buildkite_pipeline "test" { | ||
organization = "cozero" | ||
slug = "${buildkite_pipeline.test.slug}" | ||
} | ||
`, rStr) | ||
} |
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,14 @@ | ||
package buildkite | ||
|
||
// String returns a pointer to the string value passed in | ||
func String(v string) *string { | ||
return &v | ||
} | ||
|
||
// StringValue deferences a pointer to a string or returns "" if the pointer is nil | ||
func StringValue(v *string) string { | ||
if v != nil { | ||
return *v | ||
} | ||
return "" | ||
} |
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
Oops, something went wrong.