MCPcopy
hub / github.com/kubernetes-sigs/kwok / Test_formatValue

Function Test_formatValue

pkg/log/logger_ctl_test.go:183–214  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

181}
182
183func Test_formatValue(t *testing.T) {
184 type args struct {
185 val slog.Value
186 }
187 tests := []struct {
188 name string
189 args args
190 want string
191 }{
192 {
193 name: "format for error",
194 args: args{
195 val: slog.AnyValue(errors.New("unknown command \"subcommand\" for \"kwokctl\"")),
196 },
197 want: quoteIfNeed(errors.New("unknown command \"subcommand\" for \"kwokctl\"").Error()),
198 },
199 {
200 name: "format for string",
201 args: args{
202 val: slog.AnyValue("unknown command \"subcommand\" for \"kwokctl\""),
203 },
204 want: quoteIfNeed("unknown command \"subcommand\" for \"kwokctl\""),
205 },
206 }
207 for _, tt := range tests {
208 t.Run(tt.name, func(t *testing.T) {
209 if got := formatValue(tt.args.val); got != tt.want {
210 t.Errorf("formatValue() = %v, want %v", got, tt.want)
211 }
212 })
213 }
214}

Callers

nothing calls this directly

Calls 4

quoteIfNeedFunction · 0.85
formatValueFunction · 0.85
ErrorMethod · 0.80
RunMethod · 0.80

Tested by

no test coverage detected