etcdctl: import from external repo

This commit is contained in:
Brian Waldon
2014-10-22 16:59:29 -07:00
parent 9f2a42bf7d
commit 29ef918808
20 changed files with 1201 additions and 2 deletions

View File

@ -0,0 +1,56 @@
package command
import (
"bytes"
"testing"
)
func TestArgOrStdin(t *testing.T) {
tests := []struct {
args []string
stdin string
i int
w string
we error
}{
{
args: []string{
"a",
},
stdin: "b",
i: 0,
w: "a",
we: nil,
},
{
args: []string{
"a",
},
stdin: "b",
i: 1,
w: "b",
we: nil,
},
{
args: []string{
"a",
},
stdin: "",
i: 1,
w: "",
we: ErrNoAvailSrc,
},
}
for i, tt := range tests {
var b bytes.Buffer
b.Write([]byte(tt.stdin))
g, ge := argOrStdin(tt.args, &b, tt.i)
if g != tt.w {
t.Errorf("#%d: expect %v, not %v", i, tt.w, g)
}
if ge != tt.we {
t.Errorf("#%d: expect %v, not %v", i, tt.we, ge)
}
}
}