MCPcopy Create free account
hub / github.com/github/gh-aw / TestFormatResolvedValue

Function TestFormatResolvedValue

pkg/importinpututil/import_input_test.go:40–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestFormatResolvedValue(t *testing.T) {
41 tests := []struct {
42 name string
43 value any
44 want string
45 ok bool
46 }{
47 {name: "scalar string", value: "hello", want: "hello", ok: true},
48 {name: "scalar int", value: 42, want: "42", ok: true},
49 {name: "slice any", value: []any{"a", 1}, want: `["a",1]`, ok: true},
50 {name: "typed slice", value: []string{"x", "y"}, want: `["x","y"]`, ok: true},
51 {name: "map any", value: map[string]any{"k": "v"}, want: `{"k":"v"}`, ok: true},
52 {name: "typed map", value: map[string]string{"k": "v"}, want: `{"k":"v"}`, ok: true},
53 {name: "nil value", value: nil, want: "", ok: false},
54 }
55
56 for _, tt := range tests {
57 t.Run(tt.name, func(t *testing.T) {
58 got, ok := FormatResolvedValue(tt.value)
59 if ok != tt.ok {
60 t.Fatalf("FormatResolvedValue(%#v) ok = %v, want %v", tt.value, ok, tt.ok)
61 }
62 if got != tt.want {
63 t.Fatalf("FormatResolvedValue(%#v) = %q, want %q", tt.value, got, tt.want)
64 }
65 })
66 }
67}

Callers

nothing calls this directly

Calls 2

FormatResolvedValueFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected