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

Function TestExtractTargetRepoFromMap

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

Source from the content-addressed store, hash-verified

142}
143
144func TestExtractTargetRepoFromMap(t *testing.T) {
145 tests := []struct {
146 name string
147 input map[string]any
148 expected string
149 }{
150 {
151 name: "valid target-repo",
152 input: map[string]any{
153 "target-repo": "owner/repo",
154 },
155 expected: "owner/repo",
156 },
157 {
158 name: "wildcard target-repo (returns * for caller to validate)",
159 input: map[string]any{
160 "target-repo": "*",
161 },
162 expected: "*",
163 },
164 {
165 name: "missing target-repo field",
166 input: map[string]any{},
167 expected: "",
168 },
169 {
170 name: "target-repo as non-string type",
171 input: map[string]any{
172 "target-repo": 123,
173 },
174 expected: "",
175 },
176 {
177 name: "target-repo with organization and repo",
178 input: map[string]any{
179 "target-repo": "github/docs",
180 },
181 expected: "github/docs",
182 },
183 }
184
185 for _, tt := range tests {
186 t.Run(tt.name, func(t *testing.T) {
187 result := extractStringFromMap(tt.input, "target-repo", nil)
188 if result != tt.expected {
189 t.Errorf("expected %q, got %q", tt.expected, result)
190 }
191 })
192 }
193}
194
195// Integration tests to verify the helpers work correctly in the parser functions
196

Callers

nothing calls this directly

Calls 3

extractStringFromMapFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected