github.com/aimxhaisse/docker@v1.6.2/pkg/ulimit/ulimit_test.go (about)

     1  package ulimit
     2  
     3  import "testing"
     4  
     5  func TestParseInvalidLimitType(t *testing.T) {
     6  	if _, err := Parse("notarealtype=1024:1024"); err == nil {
     7  		t.Fatalf("expected error on invalid ulimit type")
     8  	}
     9  }
    10  
    11  func TestParseBadFormat(t *testing.T) {
    12  	if _, err := Parse("nofile:1024:1024"); err == nil {
    13  		t.Fatal("expected error on bad syntax")
    14  	}
    15  
    16  	if _, err := Parse("nofile"); err == nil {
    17  		t.Fatal("expected error on bad syntax")
    18  	}
    19  
    20  	if _, err := Parse("nofile="); err == nil {
    21  		t.Fatal("expected error on bad syntax")
    22  	}
    23  	if _, err := Parse("nofile=:"); err == nil {
    24  		t.Fatal("expected error on bad syntax")
    25  	}
    26  	if _, err := Parse("nofile=:1024"); err == nil {
    27  		t.Fatal("expected error on bad syntax")
    28  	}
    29  }
    30  
    31  func TestParseHardLessThanSoft(t *testing.T) {
    32  	if _, err := Parse("nofile:1024:1"); err == nil {
    33  		t.Fatal("expected error on hard limit less than soft limit")
    34  	}
    35  }
    36  
    37  func TestParseInvalidValueType(t *testing.T) {
    38  	if _, err := Parse("nofile:asdf"); err == nil {
    39  		t.Fatal("expected error on bad value type")
    40  	}
    41  }