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

Function TestSpec_PublicAPI_FormatResolvedValue

pkg/importinpututil/spec_test.go:112–139  ·  view source on GitHub ↗

TestSpec_PublicAPI_FormatResolvedValue validates the documented behavior of FormatResolvedValue as described in the package README.md. Specification: - nil returns ("", false). - Scalar values (int, bool, string, etc.) are formatted with fmt.Sprintf("%v", v). - []any and map[string]any values are J

(t *testing.T)

Source from the content-addressed store, hash-verified

110// - Typed slices and maps are normalized to []any / map[string]any and JSON-marshalled.
111// - Returns ("", false) if JSON marshalling fails.
112func TestSpec_PublicAPI_FormatResolvedValue(t *testing.T) {
113 tests := []struct {
114 name string
115 value any
116 wantStr string
117 wantOK bool
118 }{
119 // nil
120 {name: "documented: nil returns empty and false", value: nil, wantStr: "", wantOK: false},
121
122 // scalars via fmt.Sprintf("%v", v)
123 {name: "documented: scalar int", value: 42, wantStr: "42", wantOK: true},
124 {name: "documented: scalar bool", value: true, wantStr: "true", wantOK: true},
125 {name: "documented: scalar string", value: "hello", wantStr: "hello", wantOK: true},
126
127 // []any and map[string]any are JSON-marshalled
128 {name: "documented: []any slice example", value: []any{"a", "b"}, wantStr: `["a","b"]`, wantOK: true},
129 {name: "documented: map[string]any example", value: map[string]any{"x": 1}, wantStr: `{"x":1}`, wantOK: true},
130 }
131
132 for _, tt := range tests {
133 t.Run(tt.name, func(t *testing.T) {
134 s, ok := importinpututil.FormatResolvedValue(tt.value)
135 assert.Equal(t, tt.wantOK, ok, "FormatResolvedValue ok mismatch for: %s", tt.name)
136 assert.Equal(t, tt.wantStr, s, "FormatResolvedValue string mismatch for: %s", tt.name)
137 })
138 }
139}
140
141// TestSpec_PublicAPI_FormatResolvedValue_TypedCollections validates that typed
142// slices and maps are normalized and JSON-marshalled as documented.

Callers

nothing calls this directly

Calls 2

FormatResolvedValueFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected