(t *testing.T)
| 270 | } |
| 271 | |
| 272 | func TestGitPull(t *testing.T) { |
| 273 | tempDir, remoteDir := setupTestRepository(t) |
| 274 | |
| 275 | // Test case: Pull with no local changes |
| 276 | output, err := RunGitPull(context.Background(), tempDir, false, "", "origin") |
| 277 | require.NoError(t, err, "GitPull failed with no local changes") |
| 278 | require.Empty(t, output, "unexpected output from GitPull with no local changes") |
| 279 | |
| 280 | // Test case: Pull with local changes (discardLocal = false) |
| 281 | createCommit(t, tempDir, "local.txt", "local content", "local commit") |
| 282 | createRemoteCommit(t, remoteDir, "local.txt", "remote content", "remote commit") |
| 283 | output, err = RunGitPull(context.Background(), tempDir, false, "", "origin") |
| 284 | if len(output) == 0 && err == nil { |
| 285 | t.Fatalf("expected GitPull to fail with local changes and discardLocal=false, but it succeeded") |
| 286 | } |
| 287 | require.Contains(t, output, "Need to specify how to reconcile divergent branches", "unexpected output from GitPull with local changes") |
| 288 | |
| 289 | // Test case: Pull with local changes (discardLocal = true) |
| 290 | output, err = RunGitPull(context.Background(), tempDir, true, "", "origin") |
| 291 | require.NoError(t, err, "GitPull failed with local changes and discardLocal=true") |
| 292 | require.Empty(t, output, "unexpected output from GitPull with discardLocal=true") |
| 293 | |
| 294 | // Test case: Pull with remote changes |
| 295 | createRemoteCommit(t, remoteDir, "remote.txt", "remote content", "remote commit") |
| 296 | output, err = RunGitPull(context.Background(), tempDir, false, "", "origin") |
| 297 | require.NoError(t, err, "GitPull failed with remote changes") |
| 298 | require.Empty(t, output, "unexpected output from GitPull with remote changes") |
| 299 | } |
| 300 | |
| 301 | func TestRunGitPush_NoNewCommits(t *testing.T) { |
| 302 | tempDir, _ := setupTestRepository(t) |
nothing calls this directly
no test coverage detected