TestSourceFieldExtraction tests that the extractSource method works correctly
(t *testing.T)
| 179 | |
| 180 | // TestSourceFieldExtraction tests that the extractSource method works correctly |
| 181 | func 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 | } |
nothing calls this directly
no test coverage detected