aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/sync_test.go
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2014-12-18 11:25:48 +1100
committerAndrew Gerrand <adg@golang.org>2014-12-18 00:35:19 +0000
commitf473ce13dd1bba7ce531e7800fdf018f60aa2454 (patch)
treefdc20fb8b555be78ca5a4f251e04de5e77d338ea /git-codereview/sync_test.go
parent6a0c83f0c935e49b841a3a880579cb07918bcb57 (diff)
downloadgo-x-review-f473ce13dd1bba7ce531e7800fdf018f60aa2454.tar.xz
git-codereview: rename from 'git-review' to 'git-codereview'
Mostly trivial search and replace, except for hooks.go which includes a special case to remove the old git-review hooks. Change-Id: Ic0792bb3e26607e5e0ead88958e46c3ac08288cd Reviewed-on: https://go-review.googlesource.com/1741 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'git-codereview/sync_test.go')
-rw-r--r--git-codereview/sync_test.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/git-codereview/sync_test.go b/git-codereview/sync_test.go
new file mode 100644
index 0000000..0fdcbf8
--- /dev/null
+++ b/git-codereview/sync_test.go
@@ -0,0 +1,48 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "testing"
+
+func TestSync(t *testing.T) {
+ gt := newGitTest(t)
+ defer gt.done()
+
+ testMain(t, "change", "work")
+
+ // check for error with unstaged changes
+ write(t, gt.client+"/file1", "")
+ trun(t, gt.client, "git", "add", "file1")
+ write(t, gt.client+"/file1", "actual content")
+ testMainDied(t, "sync")
+ testPrintedStderr(t, "cannot sync: unstaged changes exist",
+ "git status", "git stash", "git add", "git-codereview change")
+ testNoStdout(t)
+
+ // check for error with staged changes
+ trun(t, gt.client, "git", "add", "file1")
+ testMainDied(t, "sync")
+ testPrintedStderr(t, "cannot sync: staged changes exist",
+ "git status", "!git stash", "!git add", "git-codereview change")
+ testNoStdout(t)
+
+ // check for success after stash
+ trun(t, gt.client, "git", "stash")
+ testMain(t, "sync")
+ testNoStdout(t)
+ testNoStderr(t)
+
+ // make server 1 step ahead of client
+ write(t, gt.server+"/file", "new content")
+ trun(t, gt.server, "git", "add", "file")
+ trun(t, gt.server, "git", "commit", "-m", "msg")
+
+ // check for success
+ testMain(t, "sync")
+ testNoStdout(t)
+ testNoStderr(t)
+}
+
+// TODO: Add TestSyncRebase?