Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moduli committed May 7, 2024
1 parent b2e5a12 commit cb88d8e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
29 changes: 28 additions & 1 deletion internal/provider/data_source_host_sets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,33 @@ import (
)

var (
testHostSet = `
resource "boundary_host_catalog" "foo" {
depends_on = [boundary_role.proj1_admin]
type = "static"
name = "foo"
description = "bar"
scope_id = boundary_scope.proj1.id
}
resource "boundary_host" "foo" {
depends_on = [boundary_host_catalog.foo]
type = "static"
host_catalog_id = boundary_host_catalog.foo.id
name = "host_1"
description = "My first host!"
address = "10.0.0.1"
}
resource "boundary_host_set" "foo" {
host_catalog_id = boundary_host_catalog.foo.id
type = "static"
host_ids = [
boundary_host.foo.id,
]
}
`

fooHostSetsDataMissingHostCatalogId = `
data "boundary_host_sets" "foo" {}
`
Expand All @@ -35,7 +62,7 @@ func TestAccDataSourceHostSets(t *testing.T) {
ExpectError: regexp.MustCompile("host_catalog_id: The field is incorrectly formatted."),
},
{
Config: testConfig(url, fooOrg, firstProjectFoo, fooHostset, fooHostSetsData),
Config: testConfig(url, fooOrg, firstProjectFoo, testHostSet, fooHostSetsData),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("data.boundary_host_sets.foo", "host_catalog_id"),
resource.TestCheckResourceAttr("data.boundary_host_sets.foo", "items.#", "1"),
Expand Down
21 changes: 20 additions & 1 deletion internal/provider/data_source_hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ import (
)

var (
testHost = `
resource "boundary_host_catalog" "foo" {
depends_on = [boundary_role.proj1_admin]
type = "static"
name = "foo"
description = "bar"
scope_id = boundary_scope.proj1.id
}
resource "boundary_host" "foo" {
depends_on = [boundary_host_catalog.foo]
type = "static"
host_catalog_id = boundary_host_catalog.foo.id
name = "host_1"
description = "My first host!"
address = "10.0.0.1"
}
`

fooHostsDataMissingHostCatalogId = `
data "boundary_hosts" "foo" {}
`
Expand All @@ -35,7 +54,7 @@ func TestAccDataSourceHosts(t *testing.T) {
ExpectError: regexp.MustCompile("host_catalog_id: The field is incorrectly formatted."),
},
{
Config: testConfig(url, fooOrg, firstProjectFoo, projHost, fooHostsData),
Config: testConfig(url, fooOrg, firstProjectFoo, testHost, fooHostsData),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("data.boundary_hosts.foo", "host_catalog_id"),
resource.TestCheckResourceAttr("data.boundary_hosts.foo", "items.#", "1"),
Expand Down

0 comments on commit cb88d8e

Please sign in to comment.