2017-02-06 20:54:58 +01:00
|
|
|
package fastly
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
2017-04-10 13:04:14 +02:00
|
|
|
func TestValidateLoggingFormatVersion(t *testing.T) {
|
2017-02-06 21:16:59 +01:00
|
|
|
validVersions := []int{
|
2017-02-06 20:54:58 +01:00
|
|
|
1,
|
|
|
|
2,
|
|
|
|
}
|
|
|
|
for _, v := range validVersions {
|
2017-04-10 13:04:14 +02:00
|
|
|
_, errors := validateLoggingFormatVersion(v, "format_version")
|
2017-02-06 20:54:58 +01:00
|
|
|
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{
|
2017-02-06 20:54:58 +01:00
|
|
|
0,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
}
|
|
|
|
for _, v := range invalidVersions {
|
2017-04-10 13:04:14 +02:00
|
|
|
_, errors := validateLoggingFormatVersion(v, "format_version")
|
2017-02-06 20:54:58 +01:00
|
|
|
if len(errors) != 1 {
|
|
|
|
t.Fatalf("%q should not be a valid format version", v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-10 13:04:14 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|