terraform/builtin/providers/fastly/validators_test.go

56 lines
1.1 KiB
Go
Raw Normal View History

package fastly
import "testing"
func TestValidateLoggingFormatVersion(t *testing.T) {
2017-02-06 21:16:59 +01:00
validVersions := []int{
1,
2,
}
for _, v := range validVersions {
_, errors := validateLoggingFormatVersion(v, "format_version")
if len(errors) != 0 {
t.Fatalf("%q should be a valid format version: %q", v, errors)
}
}
2017-02-06 21:16:59 +01:00
invalidVersions := []int{
0,
3,
4,
5,
}
for _, v := range invalidVersions {
_, errors := validateLoggingFormatVersion(v, "format_version")
if len(errors) != 1 {
t.Fatalf("%q should not be a valid format version", v)
}
}
}
func TestValidateLoggingMessageType(t *testing.T) {
validTypes := []string{
"classic",
"loggly",
"logplex",
"blank",
}
for _, v := range validTypes {
_, errors := validateLoggingMessageType(v, "message_type")
if len(errors) != 0 {
t.Fatalf("%q should be a valid message type: %q", v, errors)
}
}
invalidTypes := []string{
"invalid_type_1",
"invalid_type_2",
}
for _, v := range invalidTypes {
_, errors := validateLoggingMessageType(v, "message_type")
if len(errors) != 1 {
t.Fatalf("%q should not be a valid message type", v)
}
}
}