1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg/ulimit/ulimit_test.go

42 lines
1,022 B
Go
Raw Normal View History

package ulimit
import "testing"
func TestParseInvalidLimitType(t *testing.T) {
if _, err := Parse("notarealtype=1024:1024"); err == nil {
t.Fatalf("expected error on invalid ulimit type")
}
}
func TestParseBadFormat(t *testing.T) {
if _, err := Parse("nofile:1024:1024"); err == nil {
t.Fatal("expected error on bad syntax")
}
if _, err := Parse("nofile"); err == nil {
t.Fatal("expected error on bad syntax")
}
if _, err := Parse("nofile="); err == nil {
t.Fatal("expected error on bad syntax")
}
if _, err := Parse("nofile=:"); err == nil {
t.Fatal("expected error on bad syntax")
}
if _, err := Parse("nofile=:1024"); err == nil {
t.Fatal("expected error on bad syntax")
}
}
func TestParseHardLessThanSoft(t *testing.T) {
if _, err := Parse("nofile:1024:1"); err == nil {
t.Fatal("expected error on hard limit less than soft limit")
}
}
func TestParseInvalidValueType(t *testing.T) {
if _, err := Parse("nofile:asdf"); err == nil {
t.Fatal("expected error on bad value type")
}
}