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

Function TestResolvePathValue

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

Source from the content-addressed store, hash-verified

3import "testing"
4
5func TestResolvePathValue(t *testing.T) {
6 inputs := map[string]any{
7 "name": "alice",
8 "config": map[string]any{
9 "token": "abc",
10 },
11 "bad": "not-map",
12 }
13
14 tests := []struct {
15 name string
16 path string
17 want any
18 found bool
19 }{
20 {name: "top level", path: "name", want: "alice", found: true},
21 {name: "dotted path", path: "config.token", want: "abc", found: true},
22 {name: "missing top level", path: "missing", found: false},
23 {name: "missing dotted key", path: "config.missing", found: false},
24 {name: "dotted non map", path: "bad.token", found: false},
25 }
26
27 for _, tt := range tests {
28 t.Run(tt.name, func(t *testing.T) {
29 got, ok := ResolvePathValue(inputs, tt.path)
30 if ok != tt.found {
31 t.Fatalf("ResolvePathValue(%q) found = %v, want %v", tt.path, ok, tt.found)
32 }
33 if ok && got != tt.want {
34 t.Fatalf("ResolvePathValue(%q) = %#v, want %#v", tt.path, got, tt.want)
35 }
36 })
37 }
38}
39
40func TestFormatResolvedValue(t *testing.T) {
41 tests := []struct {

Callers

nothing calls this directly

Calls 2

ResolvePathValueFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected