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

     1  package fastly
     2  
     3  import "testing"
     4  
     5  func TestValidateLoggingFormatVersion(t *testing.T) {
     6  	validVersions := []int{
     7  		1,
     8  		2,
     9  	}
    10  	for _, v := range validVersions {
    11  		_, errors := validateLoggingFormatVersion(v, "format_version")
    12  		if len(errors) != 0 {
    13  			t.Fatalf("%q should be a valid format version: %q", v, errors)
    14  		}
    15  	}
    16  
    17  	invalidVersions := []int{
    18  		0,
    19  		3,
    20  		4,
    21  		5,
    22  	}
    23  	for _, v := range invalidVersions {
    24  		_, errors := validateLoggingFormatVersion(v, "format_version")
    25  		if len(errors) != 1 {
    26  			t.Fatalf("%q should not be a valid format version", v)
    27  		}
    28  	}
    29  }
    30  
    31  func TestValidateLoggingMessageType(t *testing.T) {
    32  	validTypes := []string{
    33  		"classic",
    34  		"loggly",
    35  		"logplex",
    36  		"blank",
    37  	}
    38  	for _, v := range validTypes {
    39  		_, errors := validateLoggingMessageType(v, "message_type")
    40  		if len(errors) != 0 {
    41  			t.Fatalf("%q should be a valid message type: %q", v, errors)
    42  		}
    43  	}
    44  
    45  	invalidTypes := []string{
    46  		"invalid_type_1",
    47  		"invalid_type_2",
    48  	}
    49  	for _, v := range invalidTypes {
    50  		_, errors := validateLoggingMessageType(v, "message_type")
    51  		if len(errors) != 1 {
    52  			t.Fatalf("%q should not be a valid message type", v)
    53  		}
    54  	}
    55  }