Skip to content

Commit

Permalink
Add test deploying application to custom namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
onematchfox committed Nov 22, 2022
1 parent 01a5720 commit 3d84814
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions argocd/resource_argocd_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,31 @@ func TestAccArgoCDApplication_SkipCrds(t *testing.T) {
})
}

func TestAccArgoCDApplication_CustomNamespace(t *testing.T) {
name := acctest.RandomWithPrefix("test-acc-custom-namespace")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckFeatureSupported(t, featureProjectSourceNamespaces) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccArgoCDApplicationCustomNamespace(name),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(
"argocd_application.simple",
"metadata.0.uid",
),
),
},
{
ResourceName: "argocd_application.simple",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccArgoCDApplicationSimple(name string) string {
return fmt.Sprintf(`
resource "argocd_application" "simple" {
Expand Down Expand Up @@ -1668,6 +1693,60 @@ resource "argocd_application" "crds" {
`, name)
}

func testAccArgoCDApplicationCustomNamespace(name string) string {
return fmt.Sprintf(`
resource "argocd_project" "simple" {
metadata {
name = "%[1]s"
namespace = "argocd"
}
spec {
description = "project with source namespace"
source_repos = ["*"]
source_namespaces = ["mynamespace-1"]
destination {
server = "https://kubernetes.default.svc"
namespace = "default"
}
}
}
resource "argocd_application" "simple" {
metadata {
name = "%[1]s"
namespace = "mynamespace-1"
}
spec {
project = "%[1]s"
source {
repo_url = "https://charts.bitnami.com/bitnami"
chart = "redis"
target_revision = "16.9.11"
helm {
parameter {
name = "image.tag"
value = "6.2.5"
}
parameter {
name = "architecture"
value = "standalone"
}
release_name = "testing"
}
}
destination {
server = "https://kubernetes.default.svc"
namespace = "default"
}
}
}
`, name)
}

func testAccSkipFeatureIgnoreDiffJQPathExpressions() (bool, error) {
p, _ := testAccProviders["argocd"]()
_ = p.Configure(context.Background(), &terraform.ResourceConfig{})
Expand Down

0 comments on commit 3d84814

Please sign in to comment.