Skip to content

Commit 5feb16f

Browse files
committed
gen
1 parent dd8ac27 commit 5feb16f

37 files changed

+6704
-5
lines changed

internal/provider/data_source_accounts.go

+211
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
package provider
4+
5+
import (
6+
"regexp"
7+
"testing"
8+
9+
"github.com/hashicorp/boundary/testing/controller"
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
12+
)
13+
14+
var (
15+
fooAccountDataMissingAuthMethodId = `
16+
data "boundary_accounts" "foo" {}
17+
`
18+
19+
fooAccountData = `
20+
data "boundary_accounts" "foo" {
21+
depends_on = [boundary_account.foo]
22+
auth_method_id = boundary_auth_method.foo.id
23+
}
24+
`
25+
)
26+
27+
func TestAccDataSourceAccounts(t *testing.T) {
28+
tc := controller.NewTestController(t, tcConfig...)
29+
defer tc.Shutdown()
30+
url := tc.ApiAddrs()[0]
31+
32+
var provider *schema.Provider
33+
resource.Test(t, resource.TestCase{
34+
ProviderFactories: providerFactories(&provider),
35+
Steps: []resource.TestStep{
36+
{
37+
Config: testConfig(url, fooAccountDataMissingAuthMethodId),
38+
ExpectError: regexp.MustCompile("Invalid formatted identifier."),
39+
},
40+
{
41+
Config: testConfig(url, fooOrg, fooAccount, fooAccountData),
42+
Check: resource.ComposeAggregateTestCheckFunc(
43+
resource.TestCheckResourceAttrSet("data.boundary_accounts.foo", "auth_method_id"),
44+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.#", "1"),
45+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.%", "11"),
46+
resource.TestCheckResourceAttrSet("data.boundary_accounts.foo", "items.0.auth_method_id"),
47+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.authorized_actions.#", "6"),
48+
resource.TestCheckResourceAttrSet("data.boundary_accounts.foo", "items.0.created_time"),
49+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.description", "test account"),
50+
resource.TestCheckResourceAttrSet("data.boundary_accounts.foo", "items.0.id"),
51+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.managed_group_ids.#", "0"),
52+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.name", "test"),
53+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.scope.#", "1"),
54+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.scope.0.%", "5"),
55+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.scope.0.description", ""),
56+
resource.TestCheckResourceAttrSet("data.boundary_accounts.foo", "items.0.scope.0.id"),
57+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.scope.0.name", "org1"),
58+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.scope.0.parent_scope_id", "global"),
59+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.scope.0.type", "org"),
60+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.type", "password"),
61+
resource.TestCheckResourceAttrSet("data.boundary_accounts.foo", "items.0.updated_time"),
62+
resource.TestCheckResourceAttr("data.boundary_accounts.foo", "items.0.version", "1"),
63+
),
64+
},
65+
},
66+
})
67+
}

0 commit comments

Comments
 (0)