-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
custom_location_data_source_test.go
52 lines (43 loc) · 1.55 KB
/
custom_location_data_source_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package extendedlocation_test
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
)
type CustomLocationDataSource struct{}
const (
customLocationName = "ARM_TEST_CUSTOM_LOCATION_NAME"
customLocationResourceGroupName = "ARM_TEST_CUSTOM_LOCATION_RESOURCE_GROUP_NAME"
)
func TestAccCustomLocationDataSource_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_custom_location", "test")
d := CustomLocationDataSource{}
if os.Getenv(customLocationName) == "" || os.Getenv(customLocationResourceGroupName) == "" {
t.Skipf("Skipping test due to missing environment variables: %s, %s", customLocationName, customLocationResourceGroupName)
}
data.DataSourceTestInSequence(t, []acceptance.TestStep{
{
Config: d.basic(),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("location").IsNotEmpty(),
check.That(data.ResourceName).Key("host_resource_id").IsNotEmpty(),
check.That(data.ResourceName).Key("display_name").IsNotEmpty(),
check.That(data.ResourceName).Key("namespace").IsNotEmpty(),
check.That(data.ResourceName).Key("cluster_extension_ids.#").HasValue("2"),
),
},
})
}
func (d CustomLocationDataSource) basic() string {
return fmt.Sprintf(`
provider azurerm {
features {}
}
data "azurerm_custom_location" "test" {
name = %q
resource_group_name = %q
}
`, os.Getenv(customLocationName), os.Getenv(customLocationResourceGroupName))
}