2014-04-17 17:43:01 -04:00
|
|
|
package daemon
|
2013-11-14 01:08:08 -05:00
|
|
|
|
2015-07-20 18:29:24 -04:00
|
|
|
import "testing"
|
2013-11-14 01:08:08 -05:00
|
|
|
|
|
|
|
func TestGetFullName(t *testing.T) {
|
2014-03-07 21:42:29 -05:00
|
|
|
name, err := GetFullContainerName("testing")
|
2013-11-14 01:08:08 -05:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if name != "/testing" {
|
|
|
|
t.Fatalf("Expected /testing got %s", name)
|
|
|
|
}
|
2014-03-07 21:42:29 -05:00
|
|
|
if _, err := GetFullContainerName(""); err == nil {
|
2013-11-14 01:08:08 -05:00
|
|
|
t.Fatal("Error should not be nil")
|
|
|
|
}
|
|
|
|
}
|
2014-09-12 13:45:07 -04:00
|
|
|
|
|
|
|
func TestValidContainerNames(t *testing.T) {
|
|
|
|
invalidNames := []string{"-rm", "&sdfsfd", "safd%sd"}
|
|
|
|
validNames := []string{"word-word", "word_word", "1weoid"}
|
|
|
|
|
|
|
|
for _, name := range invalidNames {
|
|
|
|
if validContainerNamePattern.MatchString(name) {
|
|
|
|
t.Fatalf("%q is not a valid container name and was returned as valid.", name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, name := range validNames {
|
|
|
|
if !validContainerNamePattern.MatchString(name) {
|
|
|
|
t.Fatalf("%q is a valid container name and was returned as invalid.", name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|