MCPcopy Index your code
hub / github.com/rilldata/rill / TestGitPull

Function TestGitPull

cli/pkg/gitutil/gitcmdwrapper_test.go:272–299  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

270}
271
272func 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
301func TestRunGitPush_NoNewCommits(t *testing.T) {
302 tempDir, _ := setupTestRepository(t)

Callers

nothing calls this directly

Calls 5

RunGitPullFunction · 0.85
ContainsMethod · 0.80
setupTestRepositoryFunction · 0.70
createCommitFunction · 0.70
createRemoteCommitFunction · 0.70

Tested by

no test coverage detected