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

Function TestSourceFieldExtraction

pkg/workflow/source_field_test.go:181–225  ·  view source on GitHub ↗

TestSourceFieldExtraction tests that the extractSource method works correctly

(t *testing.T)

Source from the content-addressed store, hash-verified

179
180// TestSourceFieldExtraction tests that the extractSource method works correctly
181func TestSourceFieldExtraction(t *testing.T) {
182 compiler := NewCompiler()
183
184 tests := []struct {
185 name string
186 frontmatter map[string]any
187 expected string
188 }{
189 {
190 name: "source_field_present",
191 frontmatter: map[string]any{
192 "source": "githubnext/agentics/workflows/ci-doctor.md@v1.0.0",
193 },
194 expected: "githubnext/agentics/workflows/ci-doctor.md@v1.0.0",
195 },
196 {
197 name: "source_field_with_spaces",
198 frontmatter: map[string]any{
199 "source": " githubnext/agentics/workflows/test.md@main ",
200 },
201 expected: "githubnext/agentics/workflows/test.md@main",
202 },
203 {
204 name: "source_field_missing",
205 frontmatter: map[string]any{},
206 expected: "",
207 },
208 {
209 name: "source_field_wrong_type",
210 frontmatter: map[string]any{
211 "source": 123,
212 },
213 expected: "",
214 },
215 }
216
217 for _, tt := range tests {
218 t.Run(tt.name, func(t *testing.T) {
219 result := compiler.extractSource(tt.frontmatter)
220 if result != tt.expected {
221 t.Errorf("extractSource() = %v, want %v", result, tt.expected)
222 }
223 })
224 }
225}

Callers

nothing calls this directly

Calls 4

extractSourceMethod · 0.95
NewCompilerFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected