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

Function TestExtractStringFromMap

pkg/workflow/config_parsing_helpers_test.go:11–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestExtractStringFromMap(t *testing.T) {
12 tests := []struct {
13 name string
14 input map[string]any
15 key string
16 expected string
17 }{
18 {
19 name: "valid string value",
20 input: map[string]any{
21 "my-key": "my-value",
22 },
23 key: "my-key",
24 expected: "my-value",
25 },
26 {
27 name: "empty string value",
28 input: map[string]any{
29 "my-key": "",
30 },
31 key: "my-key",
32 expected: "",
33 },
34 {
35 name: "missing key",
36 input: map[string]any{},
37 key: "my-key",
38 expected: "",
39 },
40 {
41 name: "non-string type",
42 input: map[string]any{
43 "my-key": 123,
44 },
45 key: "my-key",
46 expected: "",
47 },
48 {
49 name: "string with special characters",
50 input: map[string]any{
51 "my-key": "[Special] 🎯 Value",
52 },
53 key: "my-key",
54 expected: "[Special] 🎯 Value",
55 },
56 {
57 name: "different key returns different value",
58 input: map[string]any{
59 "key1": "value1",
60 "key2": "value2",
61 },
62 key: "key2",
63 expected: "value2",
64 },
65 {
66 name: "non-string value returns empty",
67 input: map[string]any{
68 "my-key": []string{"array", "value"},

Callers

nothing calls this directly

Calls 3

extractStringFromMapFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected