hub/commands/init_test.go

33 строки
782 B
Go
Исходник Обычный вид История

2013-07-05 03:18:54 +04:00
package commands
import (
"github.com/bmizerany/assert"
2014-02-10 20:22:36 +04:00
"github.com/github/hub/github"
2013-12-10 10:47:15 +04:00
"os"
2013-07-05 03:18:54 +04:00
"regexp"
"testing"
)
func TestTransformInitArgs(t *testing.T) {
2013-12-10 10:47:15 +04:00
os.Setenv("GH_PROTOCOL", "git")
2013-12-17 19:07:26 +04:00
github.CreateTestConfigs("jingweno", "123")
2013-07-05 03:18:54 +04:00
args := NewArgs([]string{"init"})
err := transformInitArgs(args)
assert.Equal(t, nil, err)
assert.Equal(t, true, args.IsParamsEmpty())
args = NewArgs([]string{"init", "-g"})
err = transformInitArgs(args)
assert.Equal(t, nil, err)
assert.Equal(t, true, args.IsParamsEmpty())
commands := args.Commands()
assert.Equal(t, 2, len(commands))
assert.Equal(t, "git init", commands[0].String())
reg := regexp.MustCompile("git remote add origin git@github.com:jingweno/.+\\.git")
assert.T(t, reg.MatchString(commands[1].String()))
}