-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into isaac/tenant-datasource
- Loading branch information
Showing
31 changed files
with
228 additions
and
34 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
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
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
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
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
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
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
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
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,63 @@ | ||
package octopusdeploy_framework | ||
|
||
import ( | ||
"fmt" | ||
"github.com/hashicorp/terraform-plugin-testing/helper/acctest" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceLifecycles(t *testing.T) { | ||
spaceName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) | ||
lifecycleName := "Default Lifecycle" | ||
resourceName := "data.octopusdeploy_lifecycles.lifecycle_default_lifecycle" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: ProtoV6ProviderFactories(), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceLifecyclesConfig(spaceName, lifecycleName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "space_id"), | ||
resource.TestCheckResourceAttr(resourceName, "partial_name", lifecycleName), | ||
resource.TestCheckResourceAttr(resourceName, "lifecycles.#", "1"), | ||
resource.TestCheckResourceAttrSet(resourceName, "lifecycles.0.id"), | ||
resource.TestCheckResourceAttr(resourceName, "lifecycles.0.name", lifecycleName), | ||
testAccCheckOutputExists("octopus_space_id"), | ||
testAccCheckOutputExists("octopus_lifecycle_id"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceLifecyclesConfig(spaceName, lifecycleName string) string { | ||
return fmt.Sprintf(` | ||
resource "octopusdeploy_space" "octopus_project_space_test" { | ||
name = "%s" | ||
is_default = false | ||
is_task_queue_stopped = false | ||
description = "Test space for lifecycles datasource" | ||
space_managers_teams = ["teams-administrators"] | ||
} | ||
data "octopusdeploy_lifecycles" "lifecycle_default_lifecycle" { | ||
ids = null | ||
partial_name = "%s" | ||
space_id = octopusdeploy_space.octopus_project_space_test.id | ||
skip = 0 | ||
take = 1 | ||
depends_on = [octopusdeploy_space.octopus_project_space_test] | ||
} | ||
output "octopus_space_id" { | ||
value = octopusdeploy_space.octopus_project_space_test.id | ||
} | ||
output "octopus_lifecycle_id" { | ||
value = data.octopusdeploy_lifecycles.lifecycle_default_lifecycle.lifecycles[0].id | ||
} | ||
`, spaceName, lifecycleName) | ||
} |
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,58 @@ | ||
package octopusdeploy_framework | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
) | ||
|
||
func TestAccDataSourceSpaces(t *testing.T) { | ||
spaceID := "Spaces-1" | ||
resourceName := "data.octopusdeploy_spaces.test" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: ProtoV6ProviderFactories(), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceSpacesConfig(spaceID), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(resourceName, "ids.#", "1"), | ||
resource.TestCheckResourceAttr(resourceName, "ids.0", spaceID), | ||
resource.TestCheckResourceAttr(resourceName, "skip", "0"), | ||
resource.TestCheckResourceAttr(resourceName, "take", "1"), | ||
resource.TestCheckResourceAttrSet(resourceName, "spaces.0.id"), | ||
testAccCheckOutputExists("octopus_space_id"), | ||
resource.TestCheckOutput("octopus_space_id", spaceID), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceSpacesConfig(spaceID string) string { | ||
tfConfig := fmt.Sprintf(` | ||
data "octopusdeploy_spaces" "test" { | ||
ids = ["%s"] | ||
skip = 0 | ||
take = 1 | ||
} | ||
output "octopus_space_id" { | ||
value = data.octopusdeploy_spaces.test.spaces[0].id | ||
} | ||
`, spaceID) | ||
return tfConfig | ||
} | ||
|
||
func testAccCheckOutputExists(name string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
_, ok := s.RootModule().Outputs[name] | ||
if !ok { | ||
return fmt.Errorf("output %s not found", name) | ||
} | ||
return nil | ||
} | ||
} |
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
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.