github.com/richardbowden/terraform@v0.6.12-0.20160901200758-30ea22c25211/terraform/semantics_test.go (about)

     1  package terraform
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestSMCUserVariables(t *testing.T) {
     8  	c := testConfig(t, "smc-uservars")
     9  
    10  	// Required variables not set
    11  	errs := smcUserVariables(c, nil)
    12  	if len(errs) == 0 {
    13  		t.Fatal("should have errors")
    14  	}
    15  
    16  	// Required variables set, optional variables unset
    17  	errs = smcUserVariables(c, map[string]interface{}{"foo": "bar"})
    18  	if len(errs) != 0 {
    19  		t.Fatalf("err: %#v", errs)
    20  	}
    21  
    22  	// Mapping element override
    23  	errs = smcUserVariables(c, map[string]interface{}{
    24  		"foo":     "bar",
    25  		"map.foo": "baz",
    26  	})
    27  	if len(errs) != 0 {
    28  		t.Fatalf("err: %#v", errs)
    29  	}
    30  
    31  	// Mapping complete override
    32  	errs = smcUserVariables(c, map[string]interface{}{
    33  		"foo": "bar",
    34  		"map": "baz",
    35  	})
    36  	if len(errs) == 0 {
    37  		t.Fatal("should have errors")
    38  	}
    39  
    40  }