File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,57 @@ func TestUlimitType(t *testing.T) {
136136 }
137137}
138138
139+ func TestUlimitString (t * testing.T ) {
140+ type args struct {
141+ values map [string ]* units.Ulimit
142+ }
143+ tests := []struct {
144+ name string
145+ args args
146+ want string
147+ }{
148+ {
149+ "get string of Ulimit with valid element" ,
150+ args {
151+ values : map [string ]* units.Ulimit {
152+ "a" : {
153+ Name : "core" ,
154+ Hard : 5 ,
155+ Soft : 3 ,
156+ },
157+ },
158+ },
159+ "[core=3:5]" ,
160+ },
161+ {
162+ "get string of Runtime with nil" ,
163+ args {
164+ values : map [string ]* units.Ulimit {},
165+ },
166+ "[]" ,
167+ },
168+ {
169+ "get string of Runtime with empty Ulimit" ,
170+ args {
171+ values : map [string ]* units.Ulimit {
172+ "a" : {},
173+ },
174+ },
175+ "[=0:0]" ,
176+ },
177+ }
178+ for _ , tt := range tests {
179+ t .Run (tt .name , func (t * testing.T ) {
180+ ul := & Ulimit {
181+ values : tt .args .values ,
182+ }
183+ if got := ul .String (); got != tt .want {
184+ t .Errorf ("Ulimit.String() = %v, want %v" , got , tt .want )
185+ }
186+ })
187+ }
188+ }
189+
139190func TestUlimitValue (t * testing.T ) {
140191 assert := assert .New (t )
141192 type args struct {
You can’t perform that action at this time.
0 commit comments