github.com/driusan/dgit@v0.0.0-20221118233547-f39f0c15edbb/git/refspec_test.go (about) 1 package git 2 3 import ( 4 "testing" 5 ) 6 7 func TestRefSpecParsing(t *testing.T) { 8 tests := []struct { 9 test RefSpec 10 wantSrc Refname 11 wantDst Refname 12 }{ 13 { 14 "refs/heads/foo", 15 "refs/heads/foo", 16 "", 17 }, 18 { 19 "+refs/heads/foo", 20 "refs/heads/foo", 21 "", 22 }, 23 { 24 "refs/heads/foo:refs/remotes/origin/foo", 25 "refs/heads/foo", 26 "refs/remotes/origin/foo", 27 }, 28 { 29 "+refs/heads/foo:refs/remotes/origin/foo", 30 "refs/heads/foo", 31 "refs/remotes/origin/foo", 32 }, 33 { 34 // XXX: Determine if this is a reasonable thing to do. 35 "refs/heads/*:refs/remotes/origin/*", 36 "refs/heads/*", 37 "refs/remotes/origin/*", 38 }, 39 } 40 for i, tc := range tests { 41 if got := tc.test.Src(); got != tc.wantSrc { 42 t.Errorf("Test %d: unexpected Src for %v. got %v want %v", i, tc.test, got, tc.wantSrc) 43 } 44 if got := tc.test.Dst(); got != tc.wantDst { 45 t.Errorf("Test %d: unexpected Dst for %v. got %v want %v", i, tc.test, got, tc.wantDst) 46 } 47 } 48 }