Files
cloudpods/pkg/scheduler/factory/plugins_test.go
T
2018-07-30 11:18:02 +08:00

28 lines
595 B
Go

package factory
import (
"testing"
)
func TestAlgorithmNameValidation(t *testing.T) {
namesShouldValidate := []string{
"1SomeAlgo1rithm",
"someAlgor-ithm1",
}
namesShouldNotValidate := []string{
"-SomeAlgorithm",
"SomeAlgorithm-",
"Some,Alg:orithm",
}
for _, name := range namesShouldValidate {
if !validName.MatchString(name) {
t.Errorf("%v should be a valid algorithm name but is not valid.", name)
}
}
for _, name := range namesShouldNotValidate {
if validName.MatchString(name) {
t.Errorf("%v should be an invalid algorithm name but is valid", name)
}
}
}