mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 17:36:38 +08:00
fix legacy tests
* remove test for removed feature * fix `TestNewCommand` test. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
@ -68,7 +68,7 @@ func TestNewCommand(t *testing.T) {
|
|||||||
buf := bytes.NewBuffer(nil)
|
buf := bytes.NewBuffer(nil)
|
||||||
|
|
||||||
// test calling "test" command
|
// test calling "test" command
|
||||||
testCmd := root.Subcommand("test")
|
testCmd := root.Subcommands["test"]
|
||||||
enc := testCmd.Encoders[oldcmds.Text]
|
enc := testCmd.Encoders[oldcmds.Text]
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
t.Fatal("got nil encoder")
|
t.Fatal("got nil encoder")
|
||||||
@ -91,7 +91,7 @@ func TestNewCommand(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// test getting subcommand
|
// test getting subcommand
|
||||||
subCmd := testCmd.Subcommand("sub")
|
subCmd := testCmd.Subcommands["sub"]
|
||||||
if subCmd == nil {
|
if subCmd == nil {
|
||||||
t.Fatal("got nil subcommand")
|
t.Fatal("got nil subcommand")
|
||||||
}
|
}
|
||||||
@ -155,32 +155,3 @@ func TestPipePair(t *testing.T) {
|
|||||||
<-wait
|
<-wait
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTeeEmitter(t *testing.T) {
|
|
||||||
req, err := cmds.NewRequest(nil, nil, nil, nil, nil, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
buf1 := bytes.NewBuffer(nil)
|
|
||||||
re1 := cmds.NewWriterResponseEmitter(WriteNopCloser{buf1}, req, cmds.Encoders[cmds.Text])
|
|
||||||
|
|
||||||
buf2 := bytes.NewBuffer(nil)
|
|
||||||
re2 := cmds.NewWriterResponseEmitter(WriteNopCloser{buf2}, req, cmds.Encoders[cmds.Text])
|
|
||||||
|
|
||||||
re := cmds.NewTeeEmitter(re1, re2)
|
|
||||||
|
|
||||||
expect := "def"
|
|
||||||
err = re.Emit(expect)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if buf1.String() != expect {
|
|
||||||
t.Fatal("expected %#v, got %#v", expect, buf1.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
if buf2.String() != expect {
|
|
||||||
t.Fatal("expected %#v, got %#v", expect, buf2.String())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user