TestRunGitStatus_Monorepo tests RunGitStatus with subpath parameter for monorepo scenarios
(t *testing.T)
| 75 | |
| 76 | // TestRunGitStatus_Monorepo tests RunGitStatus with subpath parameter for monorepo scenarios |
| 77 | func TestRunGitStatus_Monorepo(t *testing.T) { |
| 78 | tempDir, _ := setupMonorepoTestRepository(t) |
| 79 | |
| 80 | // Test case 1: Check initial status of subprojects |
| 81 | status, err := RunGitStatus(tempDir, "subproject1", "origin", "") |
| 82 | require.NoError(t, err, "RunGitStatus failed for subproject1") |
| 83 | require.Equal(t, int32(0), status.LocalCommits, "unexpected local commits for subproject1") |
| 84 | require.Equal(t, int32(0), status.RemoteCommits, "unexpected remote commits for subproject1") |
| 85 | require.False(t, status.LocalChanges, "unexpected local changes for subproject1") |
| 86 | |
| 87 | // Test case 2: Add local commit to subproject1 only |
| 88 | createCommit(t, tempDir, "subproject1/local.txt", "local content in subproject1", "subproject1: local commit") |
| 89 | require.NoError(t, GitFetch(t.Context(), tempDir, nil), "failed to fetch changes") |
| 90 | |
| 91 | status, err = RunGitStatus(tempDir, "subproject1", "origin", "") |
| 92 | require.NoError(t, err, "RunGitStatus failed for subproject1 after local commit") |
| 93 | require.Equal(t, int32(1), status.LocalCommits, "expected 1 local commit for subproject1") |
| 94 | require.Equal(t, int32(0), status.RemoteCommits, "unexpected remote commits for subproject1") |
| 95 | |
| 96 | // Test case 3: Verify subproject2 is unaffected by subproject1 changes |
| 97 | status, err = RunGitStatus(tempDir, "subproject2", "origin", "") |
| 98 | require.NoError(t, err, "RunGitStatus failed for subproject2") |
| 99 | require.Equal(t, int32(0), status.LocalCommits, "subproject2 should have no local commits") |
| 100 | require.Equal(t, int32(0), status.RemoteCommits, "subproject2 should have no remote commits") |
| 101 | } |
| 102 | |
| 103 | // TestRunGitStatus_MonorepoLocalChanges tests local changes detection in monorepo subpaths |
| 104 | func TestRunGitStatus_MonorepoLocalChanges(t *testing.T) { |
nothing calls this directly
no test coverage detected