(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func TestImportCommand_NonInteractive(t *testing.T) { |
| 34 | sourceName := "test-import-cli" |
| 35 | defer sync.Unregister(sourceName) |
| 36 | |
| 37 | sync.Register(&cliMockSource{ |
| 38 | name: sourceName, |
| 39 | tasks: []sync.ExternalTask{ |
| 40 | {ExternalID: "CLI-1", Title: "Import task one", Status: "open", URL: "https://example.com/1"}, |
| 41 | {ExternalID: "CLI-2", Title: "Import task two", Status: "open"}, |
| 42 | }, |
| 43 | }) |
| 44 | |
| 45 | tmpDir := t.TempDir() |
| 46 | origDir, _ := os.Getwd() |
| 47 | if err := os.Chdir(tmpDir); err != nil { |
| 48 | t.Fatal(err) |
| 49 | } |
| 50 | defer os.Chdir(origDir) |
| 51 | |
| 52 | resetImportFlags() |
| 53 | importSource = sourceName |
| 54 | importOutDir = filepath.Join(tmpDir, "tasks") |
| 55 | |
| 56 | err := runImport(importCmd, nil) |
| 57 | if err != nil { |
| 58 | t.Fatalf("unexpected error: %v", err) |
| 59 | } |
| 60 | |
| 61 | // Verify files were created |
| 62 | entries, err := os.ReadDir(filepath.Join(tmpDir, "tasks")) |
| 63 | if err != nil { |
| 64 | t.Fatalf("failed to read tasks dir: %v", err) |
| 65 | } |
| 66 | if len(entries) != 2 { |
| 67 | t.Errorf("expected 2 task files, got %d", len(entries)) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | func TestImportCommand_DryRun(t *testing.T) { |
| 72 | sourceName := "test-import-cli-dry" |
nothing calls this directly
no test coverage detected