Skip to content

Commit

Permalink
Add two tests for invalid service names
Browse files Browse the repository at this point in the history
  • Loading branch information
sean- committed Mar 15, 2016
1 parent 7bc3353 commit 9e8e9a1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions nomad/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,31 @@ func TestInvalidServiceCheck(t *testing.T) {
},
}
if err := s.Validate(); err == nil {
t.Fatalf("Service should be invalid")
t.Fatalf("Service should be invalid (invalid type)")
}

s = Service{
Name: "service.name",
PortLabel: "bar",
}
if err := s.Validate(); err == nil {
t.Fatalf("Service should be invalid: %v", err)
t.Fatalf("Service should be invalid (contains a dot): %v", err)
}

s = Service{
Name: "-my-service",
PortLabel: "bar",
}
if err := s.Validate(); err == nil {
t.Fatalf("Service should be invalid (begins with a hyphen): %v", err)
}

s = Service{
Name: "abcdef0123456789-abcdef0123456789-abcdef0123456789-abcdef0123456",
PortLabel: "bar",
}
if err := s.Validate(); err == nil {
t.Fatalf("Service should be invalid (too long): %v", err)
}
}

Expand Down

0 comments on commit 9e8e9a1

Please sign in to comment.