Przeglądaj źródła

Merge pull request #11778 from blatyo/fix_ulimit_string

Fix (*Ulimit).String() function. Closes #11769.
Alexander Morozov 10 lat temu
rodzic
commit
d0b2cfa1f1
2 zmienionych plików z 8 dodań i 1 usunięć
  1. 1 1
      pkg/ulimit/ulimit.go
  2. 7 0
      pkg/ulimit/ulimit_test.go

+ 1 - 1
pkg/ulimit/ulimit.go

@@ -102,5 +102,5 @@ func (u *Ulimit) GetRlimit() (*Rlimit, error) {
 }
 
 func (u *Ulimit) String() string {
-	return fmt.Sprintf("%s=%s:%s", u.Name, u.Soft, u.Hard)
+	return fmt.Sprintf("%s=%d:%d", u.Name, u.Soft, u.Hard)
 }

+ 7 - 0
pkg/ulimit/ulimit_test.go

@@ -39,3 +39,10 @@ func TestParseInvalidValueType(t *testing.T) {
 		t.Fatal("expected error on bad value type")
 	}
 }
+
+func TestStringOutput(t *testing.T) {
+	u := &Ulimit{"nofile", 1024, 512}
+	if s := u.String(); s != "nofile=512:1024" {
+		t.Fatal("expected String to return nofile=512:1024, but got", s)
+	}
+}