(t *testing.T)
| 267 | } |
| 268 | |
| 269 | func TestRunImport_FieldMapping(t *testing.T) { |
| 270 | sourceName := "test-import-mapping" |
| 271 | defer cleanupRegistry(sourceName) |
| 272 | |
| 273 | setupMockSource(sourceName, []ExternalTask{ |
| 274 | { |
| 275 | ExternalID: "EXT-1", |
| 276 | Title: "Bug fix", |
| 277 | Status: "open", |
| 278 | Priority: "high", |
| 279 | Labels: []string{"bug", "urgent"}, |
| 280 | Assignee: "bob", |
| 281 | }, |
| 282 | }) |
| 283 | |
| 284 | dir := t.TempDir() |
| 285 | outputDir := filepath.Join(dir, "tasks") |
| 286 | |
| 287 | cfg := ImportConfig{ |
| 288 | SourceName: sourceName, |
| 289 | SourceCfg: SourceConfig{Name: sourceName}, |
| 290 | OutputDir: outputDir, |
| 291 | ScanDir: dir, |
| 292 | } |
| 293 | |
| 294 | result, err := RunImport(cfg) |
| 295 | if err != nil { |
| 296 | t.Fatalf("unexpected error: %v", err) |
| 297 | } |
| 298 | |
| 299 | content, err := os.ReadFile(result.Created[0].FilePath) |
| 300 | if err != nil { |
| 301 | t.Fatalf("failed to read file: %v", err) |
| 302 | } |
| 303 | s := string(content) |
| 304 | |
| 305 | if !strings.Contains(s, "status: pending") { |
| 306 | t.Errorf("expected 'open' mapped to 'pending', got:\n%s", s) |
| 307 | } |
| 308 | if !strings.Contains(s, "priority: high") { |
| 309 | t.Errorf("expected priority 'high', got:\n%s", s) |
| 310 | } |
| 311 | if !strings.Contains(s, `"bug"`) || !strings.Contains(s, `"urgent"`) { |
| 312 | t.Errorf("expected labels mapped to tags, got:\n%s", s) |
| 313 | } |
| 314 | if !strings.Contains(s, "owner: bob") { |
| 315 | t.Errorf("expected assignee mapped to owner, got:\n%s", s) |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | func TestRunImport_SourceURLInBody(t *testing.T) { |
| 320 | sourceName := "test-import-url" |
nothing calls this directly
no test coverage detected