mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
f2aff58483
Signed-off-by: Antonio Murdaca <runcom@linux.com>
33 lines
834 B
Go
33 lines
834 B
Go
package daemon
|
|
|
|
import "testing"
|
|
|
|
func TestGetFullName(t *testing.T) {
|
|
name, err := GetFullContainerName("testing")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if name != "/testing" {
|
|
t.Fatalf("Expected /testing got %s", name)
|
|
}
|
|
if _, err := GetFullContainerName(""); err == nil {
|
|
t.Fatal("Error should not be nil")
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|