github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/review/git-review/change_test.go (about) 1 // Copyright 2014 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import "testing" 8 9 func TestChange(t *testing.T) { 10 gt := newGitTest(t) 11 defer gt.done() 12 13 t.Logf("master -> master") 14 testMain(t, "change", "master") 15 testRan(t, "git checkout -q master") 16 17 testCommitMsg = "foo: my commit msg" 18 t.Logf("master -> work") 19 testMain(t, "change", "work") 20 testRan(t, "git checkout -q -b work", 21 "git branch -q --set-upstream-to origin/master", 22 "git commit -q --allow-empty -m foo: my commit msg") 23 24 t.Logf("work -> master") 25 testMain(t, "change", "master") 26 testRan(t, "git checkout -q master") 27 28 t.Logf("master -> dev.branch") 29 testMain(t, "change", "dev.branch") 30 testRan(t, "git checkout -q -t -b dev.branch origin/dev.branch") 31 } 32 33 func TestMessageRE(t *testing.T) { 34 for _, c := range []struct { 35 in string 36 want bool 37 }{ 38 {"blah", false}, 39 {"[release-branch.go1.4] blah", false}, 40 {"[release-branch.go1.4] math: fix cosine", true}, 41 {"math: fix cosine", true}, 42 {"math/rand: make randomer", true}, 43 {"math/rand, crypto/rand: fix random sources", true}, 44 } { 45 got := messageRE.MatchString(c.in) 46 if got != c.want { 47 t.Errorf("MatchString(%q) = %v, want %v", c.in, got, c.want) 48 } 49 } 50 }