grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Merge addToKey and loadKeys
2019-05-07, Gary Kramlich
14af6e82af57
Merge addToKey and loadKeys
package
ssh
import
(
"os/exec"
"testing"
"github.com/stretchr/testify/assert"
)
type
testCase
struct
{
input
string
expected
*
exec
.
Cmd
}
func
TestRepoFromCommand
(
t
*
testing
.
T
)
{
assert
:=
assert
.
New
(
t
)
cases
:=
[]
testCase
{
{
"hg serve --stdio"
,
&
exec
.
Cmd
{
Path
:
"hg"
,
Args
:
[]
string
{
"hg"
,
"-R"
,
"repos"
,
"serve"
,
"--stdio"
},
},
},
{
"hg -R foo serve --stdio"
,
&
exec
.
Cmd
{
Path
:
"hg"
,
Args
:
[]
string
{
"hg"
,
"-R"
,
"repos/foo"
,
"serve"
,
"--stdio"
},
},
},
{
"hg -R foo/bar serve --stdio"
,
&
exec
.
Cmd
{
Path
:
"hg"
,
Args
:
[]
string
{
"hg"
,
"-R"
,
"repos/foo/bar"
,
"serve"
,
"--stdio"
},
},
},
}
for
_
,
testCase
:=
range
cases
{
cmd
,
err
:=
findCommand
(
testCase
.
input
,
"repos"
)
assert
.
Nil
(
err
)
assert
.
NotNil
(
cmd
)
assert
.
Equal
(
cmd
.
cmd
.
Args
,
testCase
.
expected
.
Args
)
}
}