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

Function TestSpec_PublicAPI_ResolvePathValue

pkg/importinpututil/spec_test.go:25–49  ·  view source on GitHub ↗

TestSpec_* functions derive from the importinpututil README.md specification. Each test maps to a documented section of the package contract and is written against the public API only — not against implementation internals. TestSpec_PublicAPI_ResolvePathValue validates the documented behavior of Res

(t *testing.T)

Source from the content-addressed store, hash-verified

23// - Returns (value, true) on success.
24// - Returns (nil, false) when the key is absent or the dotted path cannot be traversed.
25func TestSpec_PublicAPI_ResolvePathValue(t *testing.T) {
26 inputs := map[string]any{
27 "count": 42,
28 "config": map[string]any{"apiKey": "secret"},
29 }
30
31 tests := []struct {
32 name string
33 inputPath string
34 wantValue any
35 wantOK bool
36 }{
37 {name: "documented: top-level key", inputPath: "count", wantValue: 42, wantOK: true},
38 {name: "documented: dotted sub-key", inputPath: "config.apiKey", wantValue: "secret", wantOK: true},
39 {name: "documented: missing top-level key", inputPath: "missing", wantValue: nil, wantOK: false},
40 }
41
42 for _, tt := range tests {
43 t.Run(tt.name, func(t *testing.T) {
44 value, ok := importinpututil.ResolvePathValue(inputs, tt.inputPath)
45 assert.Equal(t, tt.wantOK, ok, "ResolvePathValue(%q) ok mismatch for: %s", tt.inputPath, tt.name)
46 assert.Equal(t, tt.wantValue, value, "ResolvePathValue(%q) value mismatch for: %s", tt.inputPath, tt.name)
47 })
48 }
49}
50
51// TestSpec_PublicAPI_ResolvePathValue_DottedPathTraversalFailure validates the
52// documented "(nil, false)" result when a dotted path cannot be traversed.

Callers

nothing calls this directly

Calls 2

ResolvePathValueFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected