Skip to content

Commit

Permalink
Update workspace and user IDs in test configs
Browse files Browse the repository at this point in the history
  • Loading branch information
htahir1 committed Oct 28, 2024
1 parent b802920 commit 2ef05c4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
18 changes: 7 additions & 11 deletions internal/provider/resource_service_connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provider

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand All @@ -29,11 +30,9 @@ func TestAccServiceConnector_basic(t *testing.T) {
"zenml_service_connector.test", "configuration.project_id", "test-project"),
// Add resource_types validation
resource.TestCheckResourceAttr(
"zenml_service_connector.test", "resource_types.#", "2"),
"zenml_service_connector.test", "resource_types.#", "1"),
resource.TestCheckResourceAttr(
"zenml_service_connector.test", "resource_types.0", "artifact-store"),
resource.TestCheckResourceAttr(
"zenml_service_connector.test", "resource_types.1", "container-registry"),
// Add at least one secrets check
resource.TestCheckResourceAttrSet(
"zenml_service_connector.test", "secrets.service_account_json"),
Expand Down Expand Up @@ -118,18 +117,15 @@ func testAccCheckServiceConnectorDestroy(s *terraform.State) error {
}

func testAccServiceConnectorConfig_basic() string {
return `
return fmt.Sprintf(`
resource "zenml_service_connector" "test" {
name = "test-connector"
type = "gcp"
auth_method = "service-account"
user = "user-uuid"
workspace = "workspace-uuid"
workspace = "%s"
user = "%s"
resource_types = [
"artifact-store",
"container-registry"
]
resource_types = ["artifact-store"]
configuration = {
project_id = "test-project"
Expand All @@ -146,7 +142,7 @@ resource "zenml_service_connector" "test" {
environment = "test"
}
}
`
`, os.Getenv("ZENML_WORKSPACE"), os.Getenv("ZENML_USER_ID"))
}

func testAccServiceConnectorConfig_update() string {
Expand Down
28 changes: 14 additions & 14 deletions internal/provider/resource_stack_component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provider

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand All @@ -24,7 +25,7 @@ func TestAccStackComponent_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"zenml_stack_component.test", "type", "artifact_store"),
resource.TestCheckResourceAttr(
"zenml_stack_component.test", "flavor", "gcp"),
"zenml_stack_component.test", "flavor", "local"),
),
},
{
Expand Down Expand Up @@ -128,45 +129,44 @@ func testAccCheckStackComponentDestroy(s *terraform.State) error {
}

func testAccStackComponentConfig_basic() string {
return `
return fmt.Sprintf(`
resource "zenml_stack_component" "test" {
name = "test-store"
type = "artifact_store"
flavor = "gcp"
user = "user-uuid"
workspace = "workspace-uuid"
flavor = "local"
workspace = "%s"
user = "%s"
configuration = {
path = "gs://test-bucket/artifacts"
path = "/tmp/artifacts"
}
labels = {
environment = "test"
}
}
`
`, os.Getenv("ZENML_WORKSPACE"), os.Getenv("ZENML_USER_ID"))
}

func testAccStackComponentConfig_update() string {
return `
return fmt.Sprintf(`
resource "zenml_stack_component" "test" {
name = "updated-store"
type = "artifact_store"
flavor = "gcp"
user = "user-uuid"
workspace = "workspace-uuid"
flavor = "local"
workspace = "%s"
user = "%s"
configuration = {
path = "gs://test-bucket/artifacts"
location = "us-central1"
path = "/tmp/artifacts-updated"
}
labels = {
environment = "staging"
team = "ml"
}
}
`
`, os.Getenv("ZENML_WORKSPACE"), os.Getenv("ZENML_USER_ID"))
}

func testAccStackComponentConfig_withConnector() string {
Expand Down
34 changes: 25 additions & 9 deletions internal/provider/resource_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"os"
)

func TestAccStack_basic(t *testing.T) {
Expand All @@ -26,17 +27,32 @@ func TestAccStack_basic(t *testing.T) {
}

func testAccStackConfig_basic() string {
return `
return fmt.Sprintf(`
resource "zenml_stack_component" "artifact_store" {
name = "test-store"
type = "artifact_store"
flavor = "local"
workspace = "%s"
user = "%s"
configuration = {
path = "/tmp/artifacts"
}
}
resource "zenml_stack" "test" {
name = "test-stack"
components = {
"artifact_store" = "test-store-id"
}
labels = {
"environment" = "test"
}
name = "test-stack"
workspace = "%s"
components = {
"artifact_store" = zenml_stack_component.artifact_store.id
}
labels = {
environment = "test"
}
}
`
`, os.Getenv("ZENML_WORKSPACE"), os.Getenv("ZENML_USER_ID"), os.Getenv("ZENML_WORKSPACE"))
}

func testAccCheckStackDestroy(s *terraform.State) error {
Expand Down

0 comments on commit 2ef05c4

Please sign in to comment.