github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/opc/data_source_virtual_nic_test.go (about)

     1  package opc
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/helper/acctest"
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  )
    10  
    11  func TestAccOPCVNIC_Basic(t *testing.T) {
    12  	rInt := acctest.RandInt()
    13  
    14  	resource.Test(t, resource.TestCase{
    15  		PreCheck:  func() { testAccPreCheck(t) },
    16  		Providers: testAccProviders,
    17  		Steps: []resource.TestStep{
    18  			{
    19  				Config: testAccVnicBasic(rInt),
    20  				Check: resource.ComposeTestCheckFunc(
    21  					resource.TestCheckResourceAttr(
    22  						"data.opc_compute_vnic.foo", "mac_address", "02:5a:cd:ec:2e:4c"),
    23  					resource.TestCheckResourceAttr(
    24  						"data.opc_compute_vnic.foo", "transit_flag", "false"),
    25  				),
    26  			},
    27  		},
    28  	})
    29  }
    30  
    31  func testAccVnicBasic(rInt int) string {
    32  	return fmt.Sprintf(`
    33  resource "opc_compute_ip_network" "foo" {
    34    name = "testing-vnic-data-%d"
    35    description = "testing-vnic-data"
    36    ip_address_prefix = "10.1.13.0/24"
    37  }
    38  
    39  resource "opc_compute_instance" "test" {
    40    name = "test-%d"
    41    label = "test"
    42    shape = "oc3"
    43    image_list = "/oracle/public/oel_6.7_apaas_16.4.5_1610211300"
    44    networking_info {
    45      index = 0
    46      ip_network = "${opc_compute_ip_network.foo.id}"
    47      vnic = "test-vnic-data-%d"
    48      shared_network = false
    49      mac_address = "02:5a:cd:ec:2e:4c"
    50    }
    51  }
    52  
    53  data "opc_compute_network_interface" "eth0" {
    54    instance_name = "${opc_compute_instance.test.name}"
    55    instance_id = "${opc_compute_instance.test.id}"
    56    interface = "eth0"
    57  }
    58  
    59  data "opc_compute_vnic" "foo" {
    60    name = "${data.opc_compute_network_interface.eth0.vnic}"
    61  }`, rInt, rInt, rInt)
    62  }