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

Function TestProjectRegister_CWD

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

Source from the content-addressed store, hash-verified

33}
34
35func TestProjectRegister_CWD(t *testing.T) {
36 resetProjectRegistryFlags()
37 projDir := createProjectDir(t)
38 globalCfg := filepath.Join(t.TempDir(), ".taskmd.yaml")
39 t.Setenv("TASKMD_HOME_CONFIG", globalCfg)
40
41 // chdir to the project directory
42 origDir, err := os.Getwd()
43 if err != nil {
44 t.Fatal(err)
45 }
46 t.Cleanup(func() { os.Chdir(origDir) })
47 if err := os.Chdir(projDir); err != nil {
48 t.Fatal(err)
49 }
50
51 err = runProjectRegister(projectRegisterCmd, []string{})
52 if err != nil {
53 t.Fatalf("unexpected error: %v", err)
54 }
55
56 entries, err := LoadGlobalRegistry()
57 if err != nil {
58 t.Fatalf("failed to load registry: %v", err)
59 }
60 if len(entries) != 1 {
61 t.Fatalf("expected 1 entry, got %d", len(entries))
62 }
63 if entries[0].ID != filepath.Base(projDir) {
64 t.Errorf("expected ID %q, got %q", filepath.Base(projDir), entries[0].ID)
65 }
66 if entries[0].Path != projDir {
67 t.Errorf("expected path %q, got %q", projDir, entries[0].Path)
68 }
69}
70
71func TestProjectRegister_ExplicitPath(t *testing.T) {
72 resetProjectRegistryFlags()

Callers

nothing calls this directly

Calls 4

createProjectDirFunction · 0.85
runProjectRegisterFunction · 0.85
LoadGlobalRegistryFunction · 0.85

Tested by

no test coverage detected