github.com/peterbale/terraform@v0.9.0-beta2.0.20170315142748-5723acd55547/builtin/providers/consul/data_source_consul_catalog_service_test.go (about)

     1  package consul
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/terraform/helper/resource"
     7  )
     8  
     9  func TestAccDataConsulCatalogService_basic(t *testing.T) {
    10  	resource.Test(t, resource.TestCase{
    11  		Providers: testAccProviders,
    12  		Steps: []resource.TestStep{
    13  			resource.TestStep{
    14  				Config: testAccDataConsulCatalogServiceConfig,
    15  				Check: resource.ComposeTestCheckFunc(
    16  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "datacenter", "dc1"),
    17  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.#", "1"),
    18  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.address", "<all>"),
    19  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.create_index", "<any>"),
    20  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.enable_tag_override", "<any>"),
    21  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.id", "<any>"),
    22  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.modify_index", "<any>"),
    23  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.name", "<any>"),
    24  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.node_address", "<any>"),
    25  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.node_id", "<any>"),
    26  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.node_meta.%", "0"),
    27  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.node_name", "<any>"),
    28  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.port", "<any>"),
    29  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.tagged_addresses.%", "2"),
    30  					testAccCheckDataSourceValue("data.consul_catalog_service.read", "service.0.tags.#", "0"),
    31  				),
    32  			},
    33  		},
    34  	})
    35  }
    36  
    37  const testAccDataConsulCatalogServiceConfig = `
    38  data "consul_catalog_service" "read" {
    39    query_options {
    40      allow_stale = true
    41      require_consistent = false
    42      token = ""
    43      wait_index = 0
    44      wait_time = "1m"
    45    }
    46  
    47    name = "consul"
    48  }
    49  `