Skip to content

Commit 6e7f31b

Browse files
committed
test: add new checkpoint for apis/opts/config/ulimit.go
Signed-off-by: WillSmisi <[email protected]>
1 parent 22bfd53 commit 6e7f31b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

apis/opts/config/ulimit_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
139190
func TestUlimitValue(t *testing.T) {
140191
assert := assert.New(t)
141192
type args struct {

0 commit comments

Comments
 (0)