diff options
| author | Russ Cox <rsc@golang.org> | 2015-01-30 13:35:06 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2015-01-30 19:31:56 +0000 |
| commit | 008ea1ee6a807eecb6bef31df8508695a4e42702 (patch) | |
| tree | efac32502f9beaa55264563a1f2e0e0349afb8c5 /git-codereview/sync_test.go | |
| parent | 28fbeb1f505cc97fa0ebb1eefc62d65749cfdfb5 (diff) | |
| download | go-x-review-008ea1ee6a807eecb6bef31df8508695a4e42702.tar.xz | |
git-codereview: fix bug in sync for multi-commit client
When deciding whether to discard the commit info for
the final commit, it was using the first commit instead of
the final one.
Change-Id: I2304fba6fa82a1d21600c3caa08b6b119edcdb7f
Reviewed-on: https://go-review.googlesource.com/3628
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'git-codereview/sync_test.go')
| -rw-r--r-- | git-codereview/sync_test.go | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/git-codereview/sync_test.go b/git-codereview/sync_test.go index 0fdcbf8..2f7318d 100644 --- a/git-codereview/sync_test.go +++ b/git-codereview/sync_test.go @@ -45,4 +45,61 @@ func TestSync(t *testing.T) { testNoStderr(t) } -// TODO: Add TestSyncRebase? +func TestSyncRebase(t *testing.T) { + gt := newGitTest(t) + defer gt.done() + + // client 3 ahead + gt.work(t) + gt.work(t) + gt.work(t) + + b := CurrentBranch() + if len(b.Pending()) != 3 { + t.Fatalf("have %d pending CLs, want 3", len(b.Pending())) + } + top := b.Pending()[0].Hash + + // check for success for sync no-op + testMain(t, "sync") + testNoStdout(t) + testNoStderr(t) + + b = CurrentBranch() + if len(b.Pending()) != 3 { + t.Fatalf("have %d pending CLs after no-op sync, want 3", len(b.Pending())) + } + if b.Pending()[0].Hash != top { + t.Fatalf("CL hashes changed during no-op sync") + } + + // submit first two CLs - gt.serverWork does same thing gt.work does, but on client + gt.serverWork(t) + gt.serverWork(t) + + testMain(t, "sync") + testNoStdout(t) + testNoStderr(t) + + // there should be one left, and it should be a different hash + b = CurrentBranch() + if len(b.Pending()) != 1 { + t.Fatalf("have %d pending CLs after submitting two, want 1", len(b.Pending())) + } + if b.Pending()[0].Hash == top { + t.Fatalf("CL hashes DID NOT change during sync after submit") + } + + // submit final change + gt.serverWork(t) + + testMain(t, "sync") + testNoStdout(t) + testNoStderr(t) + + // there should be none left + b = CurrentBranch() + if len(b.Pending()) != 0 { + t.Fatalf("have %d pending CLs after final sync, want 0", len(b.Pending())) + } +} |
