Skip to content

Commit

Permalink
add new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moduli committed Jul 12, 2024
1 parent d2e52b8 commit 9dab55f
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
69 changes: 69 additions & 0 deletions internal/provider/data_source_aliases_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
"regexp"
"testing"

"github.com/hashicorp/boundary/testing/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

var (
fooAliasesDataMissingScope = `
data "boundary_aliases" "foo" {}
`

fooAliasesData = `
data "boundary_aliases" "foo" {
depends_on = [boundary_alias_target.example]
scope_id = boundary_alias_target.example.scope_id
}
`
)

func TestAccDataSourceAliases(t *testing.T) {
tc := controller.NewTestController(t, tcConfig...)
defer tc.Shutdown()
url := tc.ApiAddrs()[0]

res := targetAliasResource(targetAliasName, targetAliasDesc, targetAliasValue)

var provider *schema.Provider
resource.Test(t, resource.TestCase{
ProviderFactories: providerFactories(&provider),
Steps: []resource.TestStep{
{
Config: testConfig(url, fooAliasesDataMissingScope),
ExpectError: regexp.MustCompile(""),
},
{
Config: testConfig(url, fooOrg, firstProjectFoo, fooBarTarget, res, fooAliasesData),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.#", "1"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.%", "12"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.authorized_actions.#", "4"),
resource.TestCheckResourceAttrSet("data.boundary_aliases.foo", "items.0.created_time"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.description", "the foo"),
resource.TestCheckResourceAttrSet("data.boundary_aliases.foo", "items.0.destination_id"),
resource.TestCheckResourceAttrSet("data.boundary_aliases.foo", "items.0.id"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.name", "foo"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.scope.#", "1"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.scope.0.%", "5"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.scope.0.description", "Global Scope"),
resource.TestCheckResourceAttrSet("data.boundary_aliases.foo", "items.0.scope.0.id"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.scope.0.name", "global"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.scope.0.parent_scope_id", ""),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.scope.0.type", "global"),
resource.TestCheckResourceAttrSet("data.boundary_aliases.foo", "items.0.scope_id"),
resource.TestCheckResourceAttrSet("data.boundary_aliases.foo", "items.0.updated_time"),
resource.TestCheckResourceAttr("data.boundary_aliases.foo", "items.0.version", "1"),
resource.TestCheckResourceAttrSet("data.boundary_aliases.foo", "scope_id"),
),
},
},
})
}
4 changes: 4 additions & 0 deletions internal/provider/data_source_credentials_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider
4 changes: 4 additions & 0 deletions internal/provider/data_source_policies_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider
4 changes: 4 additions & 0 deletions internal/provider/data_source_session_recordings_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider
4 changes: 4 additions & 0 deletions internal/provider/data_source_storage_buckets_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider
4 changes: 4 additions & 0 deletions internal/provider/data_source_workers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

0 comments on commit 9dab55f

Please sign in to comment.