Skip to content

Commit

Permalink
add new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moduli committed Jun 6, 2024
1 parent d2e52b8 commit 97dd7f8
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 0 deletions.
74 changes: 74 additions & 0 deletions internal/provider/data_source_aliases_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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_users.foo", "items.0.%", "15"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.account_ids.#", "0"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.accounts.#", "0"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.authorized_actions.#", "8"),
// resource.TestCheckResourceAttrSet("data.boundary_users.foo", "items.0.created_time"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.description", "bar"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.email", ""),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.full_name", ""),
// resource.TestCheckResourceAttrSet("data.boundary_users.foo", "items.0.id"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.login_name", ""),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.name", "test"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.primary_account_id", ""),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.scope.#", "1"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.scope.0.%", "5"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.scope.0.description", ""),
// resource.TestCheckResourceAttrSet("data.boundary_users.foo", "items.0.scope.0.id"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.scope.0.name", "org1"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.scope.0.parent_scope_id", "global"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.scope.0.type", "org"),
// resource.TestCheckResourceAttrSet("data.boundary_users.foo", "items.0.scope_id"),
// resource.TestCheckResourceAttrSet("data.boundary_users.foo", "items.0.updated_time"),
// resource.TestCheckResourceAttr("data.boundary_users.foo", "items.0.version", "1"),
// resource.TestCheckResourceAttrSet("data.boundary_users.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 97dd7f8

Please sign in to comment.