github.com/lymingtonprecision/terraform@v0.9.9-0.20170613092852-62acef9611a9/builtin/providers/test/resource_gh12183.go (about)

     1  package test
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/helper/schema"
     5  )
     6  
     7  // This is a test resource to help reproduce GH-12183. This issue came up
     8  // as a complex mixing of core + helper/schema and while we added core tests
     9  // to cover some of the cases, this test helps top it off with an end-to-end
    10  // test.
    11  func testResourceGH12183() *schema.Resource {
    12  	return &schema.Resource{
    13  		Create: testResourceCreate_gh12183,
    14  		Read:   testResourceRead_gh12183,
    15  		Update: testResourceUpdate_gh12183,
    16  		Delete: testResourceDelete_gh12183,
    17  		Schema: map[string]*schema.Schema{
    18  			"key": &schema.Schema{
    19  				Type:     schema.TypeString,
    20  				Optional: true,
    21  			},
    22  
    23  			"config": &schema.Schema{
    24  				Type:     schema.TypeList,
    25  				Optional: true,
    26  				ForceNew: true,
    27  				MinItems: 1,
    28  				Elem: &schema.Resource{
    29  					Schema: map[string]*schema.Schema{
    30  						"name": {
    31  							Type:     schema.TypeString,
    32  							Required: true,
    33  						},
    34  
    35  						"rules": {
    36  							Type:     schema.TypeSet,
    37  							Computed: true,
    38  							Elem:     &schema.Schema{Type: schema.TypeString},
    39  							Set:      schema.HashString,
    40  						},
    41  					},
    42  				},
    43  			},
    44  		},
    45  	}
    46  }
    47  
    48  func testResourceCreate_gh12183(d *schema.ResourceData, meta interface{}) error {
    49  	d.SetId("testId")
    50  	return testResourceRead(d, meta)
    51  }
    52  
    53  func testResourceRead_gh12183(d *schema.ResourceData, meta interface{}) error {
    54  	return nil
    55  }
    56  
    57  func testResourceUpdate_gh12183(d *schema.ResourceData, meta interface{}) error {
    58  	return nil
    59  }
    60  
    61  func testResourceDelete_gh12183(d *schema.ResourceData, meta interface{}) error {
    62  	d.SetId("")
    63  	return nil
    64  }