2013-07-05 03:18:54 +04:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/bmizerany/assert"
|
|
|
|
"github.com/jingweno/gh/github"
|
|
|
|
"regexp"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTransformInitArgs(t *testing.T) {
|
2013-12-08 07:27:53 +04:00
|
|
|
github.CreateTestConfig("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()))
|
|
|
|
}
|