From 565f1712ba8c42fcca03d5df1af5b8ec12dd9d2b Mon Sep 17 00:00:00 2001 From: Lourens de Jager <165963988+lourens-octopus@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:57:56 +1300 Subject: [PATCH] test --- .../resource_git_trigger_test.go | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/octopusdeploy_framework/resource_git_trigger_test.go b/octopusdeploy_framework/resource_git_trigger_test.go index d0b8658c..4f3b3465 100644 --- a/octopusdeploy_framework/resource_git_trigger_test.go +++ b/octopusdeploy_framework/resource_git_trigger_test.go @@ -174,7 +174,7 @@ func testAssertGitTriggerAttributes(expected gitTriggerTestData, prefix string) resource.TestCheckResourceAttr(prefix, "project_id", expected.projectId), resource.TestCheckResourceAttr(prefix, "channel_id", expected.channelId), resource.TestCheckResourceAttr(prefix, "is_disabled", strconv.FormatBool(expected.isDisabled)), - resource.TestCheckResourceAttr(prefix, "sources", convertGitTriggerSourcesToString(expected.sources)), + resource.TestCheckResourceAttr(prefix, "sources.0", convertGitTriggerSourceToString(expected.sources[0])), ) } @@ -186,7 +186,7 @@ func testGitTriggerCheckDestroy(s *terraform.State) error { projectTrigger, err := octoClient.ProjectTriggers.GetByID(rs.Primary.ID) if err == nil && projectTrigger != nil { - return fmt.Errorf("azure container registry feed (%s) still exists", rs.Primary.ID) + return fmt.Errorf("git trigger (%s) still exists", rs.Primary.ID) } } @@ -212,6 +212,25 @@ func convertGitTriggerSourcesToString(sources []gitTriggerSourcesTestData) strin return result } +func convertGitTriggerSourceToString(source gitTriggerSourcesTestData) string { + var result string + + result += fmt.Sprintf(` + { + deployment_action_slug = "%s" + git_dependency_name = "%s" + include_file_paths = [%s] + exclude_file_paths = [%s] + }`, + source.deploymentActionSlug, + source.gitDependencyName, + convertStringSliceToString(source.includeFilePaths), + convertStringSliceToString(source.excludeFilePaths), + ) + + return result +} + func convertStringSliceToString(slice []string) string { return fmt.Sprintf(`"%s"`, strings.Join(slice, `", "`)) }