MCPcopy Create free account
hub / github.com/driangle/taskmd / TestImportCommand_NonInteractive

Function TestImportCommand_NonInteractive

apps/cli/internal/cli/importcmd_test.go:33–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func 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
71func TestImportCommand_DryRun(t *testing.T) {
72 sourceName := "test-import-cli-dry"

Callers

nothing calls this directly

Calls 2

resetImportFlagsFunction · 0.85
runImportFunction · 0.85

Tested by

no test coverage detected