Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
lourens-octopus committed Dec 5, 2024
1 parent de5bb07 commit 565f171
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions octopusdeploy_framework/resource_git_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])),
)
}

Expand All @@ -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)
}
}

Expand All @@ -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, `", "`))
}

0 comments on commit 565f171

Please sign in to comment.