github.com/pengwynn/gh@v1.0.1-0.20140118055701-14327ca3942e/commands/submodule_test.go (about)

     1  package commands
     2  
     3  import (
     4  	"github.com/bmizerany/assert"
     5  	"github.com/jingweno/gh/github"
     6  	"testing"
     7  )
     8  
     9  func TestTransformSubmoduleArgs(t *testing.T) {
    10  	github.CreateTestConfigs("jingweno", "123")
    11  
    12  	args := NewArgs([]string{"submodule", "add", "jingweno/gh", "vendor/gh"})
    13  	transformSubmoduleArgs(args)
    14  
    15  	cmds := args.Commands()
    16  	assert.Equal(t, 1, len(cmds))
    17  	assert.Equal(t, "git submodule add git://github.com/jingweno/gh.git vendor/gh", cmds[0].String())
    18  
    19  	args = NewArgs([]string{"submodule", "add", "-p", "jingweno/gh",
    20  		"vendor/gh"})
    21  	transformSubmoduleArgs(args)
    22  
    23  	cmds = args.Commands()
    24  	assert.Equal(t, 1, len(cmds))
    25  	assert.Equal(t, "git submodule add git@github.com:jingweno/gh.git vendor/gh", cmds[0].String())
    26  
    27  	args = NewArgs([]string{"submodule", "add", "-b", "gh", "--name", "gh", "jingweno/gh", "vendor/gh"})
    28  	transformSubmoduleArgs(args)
    29  
    30  	cmds = args.Commands()
    31  	assert.Equal(t, 1, len(cmds))
    32  	assert.Equal(t, "git submodule add -b gh --name gh git://github.com/jingweno/gh.git vendor/gh", cmds[0].String())
    33  }