(t *testing.T)
| 33 | } |
| 34 | |
| 35 | func 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 | |
| 71 | func TestProjectRegister_ExplicitPath(t *testing.T) { |
| 72 | resetProjectRegistryFlags() |
nothing calls this directly
no test coverage detected