hub/commands/cherry_pick_test.go

51 строка
1.4 KiB
Go
Исходник Обычный вид История

2013-07-20 09:46:47 +04:00
package commands
import (
2013-12-10 10:47:15 +04:00
"os"
2013-07-20 09:46:47 +04:00
"testing"
"github.com/bmizerany/assert"
"github.com/github/hub/fixtures"
2013-07-20 09:46:47 +04:00
)
func TestParseCherryPickProjectAndSha(t *testing.T) {
testConfigs := fixtures.SetupTestConfigs()
defer testConfigs.TearDown()
2013-07-20 09:46:47 +04:00
ref := "https://github.com/jingweno/gh/commit/a319d88#comments"
project, sha := parseCherryPickProjectAndSha(ref)
assert.Equal(t, "jingweno", project.Owner)
assert.Equal(t, "gh", project.Name)
assert.Equal(t, "github.com", project.Host)
assert.Equal(t, "https", project.Protocol)
2013-07-20 09:46:47 +04:00
assert.Equal(t, "a319d88", sha)
ref = "https://github.com/jingweno/gh/commit/a319d88#comments"
project, sha = parseCherryPickProjectAndSha(ref)
assert.Equal(t, "jingweno", project.Owner)
assert.Equal(t, "gh", project.Name)
assert.Equal(t, "a319d88", sha)
}
func TestTransformCherryPickArgs(t *testing.T) {
testConfigs := fixtures.SetupTestConfigs()
defer testConfigs.TearDown()
args := NewArgs([]string{})
transformCherryPickArgs(args)
cmds := args.Commands()
assert.Equal(t, 1, len(cmds))
2014-04-08 08:19:57 +04:00
os.Setenv("HUB_PROTOCOL", "git")
defer os.Setenv("HUB_PROTOCOL", "")
args = NewArgs([]string{"cherry-pick", "https://github.com/jingweno/gh/commit/a319d88#comments"})
2013-07-20 09:46:47 +04:00
transformCherryPickArgs(args)
cmds = args.Commands()
2013-07-20 09:46:47 +04:00
assert.Equal(t, 2, len(cmds))
assert.Equal(t, "git remote add -f jingweno git://github.com/jingweno/gh.git", cmds[0].String())
assert.Equal(t, "git cherry-pick a319d88", cmds[1].String())
}