github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/azurerm/data_source_arm_client_config_test.go (about)

     1  package azurerm
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/helper/resource"
     8  	"github.com/hashicorp/terraform/terraform"
     9  )
    10  
    11  func TestAccAzureRMClientConfig_basic(t *testing.T) {
    12  	clientId := os.Getenv("ARM_CLIENT_ID")
    13  	tenantId := os.Getenv("ARM_TENANT_ID")
    14  	subscriptionId := os.Getenv("ARM_SUBSCRIPTION_ID")
    15  
    16  	resource.Test(t, resource.TestCase{
    17  		PreCheck:  func() { testAccPreCheck(t) },
    18  		Providers: testAccProviders,
    19  		Steps: []resource.TestStep{
    20  			{
    21  				Config: testAccCheckArmClientConfig_basic,
    22  				Check: resource.ComposeTestCheckFunc(
    23  					testAzureRMClientConfigAttr("data.azurerm_client_config.current", "client_id", clientId),
    24  					testAzureRMClientConfigAttr("data.azurerm_client_config.current", "tenant_id", tenantId),
    25  					testAzureRMClientConfigAttr("data.azurerm_client_config.current", "subscription_id", subscriptionId),
    26  				),
    27  			},
    28  		},
    29  	})
    30  }
    31  
    32  // Wraps resource.TestCheckResourceAttr to prevent leaking values to console
    33  // in case of mismatch
    34  func testAzureRMClientConfigAttr(name, key, value string) resource.TestCheckFunc {
    35  	return func(s *terraform.State) error {
    36  		err := resource.TestCheckResourceAttr(name, key, value)(s)
    37  		if err != nil {
    38  			// return fmt.Errorf("%s: Attribute '%s', failed check (values hidden)", name, key)
    39  			return err
    40  		}
    41  
    42  		return nil
    43  	}
    44  }
    45  
    46  const testAccCheckArmClientConfig_basic = `
    47  data "azurerm_client_config" "current" { }
    48  `