fix test & update structure
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -22,3 +22,4 @@ _testmain.go
|
|||||||
*.exe
|
*.exe
|
||||||
*.test
|
*.test
|
||||||
*.prof
|
*.prof
|
||||||
|
gosh
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testPluginsDir = "../plugins"
|
testPluginsDir = "./plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestShellNew(t *testing.T) {
|
func TestShellNew(t *testing.T) {
|
||||||
shell := New()
|
shell := New()
|
||||||
if shell.pluginsDir != pluginsDir {
|
if shell.pluginsDir != testPluginsDir {
|
||||||
t.Error("pluginsDir not set")
|
t.Error("pluginsDir not set")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,10 +49,10 @@ func TestShellHandle(t *testing.T) {
|
|||||||
|
|
||||||
helloOut := bytes.NewBufferString("")
|
helloOut := bytes.NewBufferString("")
|
||||||
shell.ctx = context.WithValue(context.TODO(), "gosh.stdout", helloOut)
|
shell.ctx = context.WithValue(context.TODO(), "gosh.stdout", helloOut)
|
||||||
if err := shell.handle("testhello"); err == nil {
|
if _, err := shell.handle(shell.ctx, "testhello"); err == nil {
|
||||||
t.Error("this test should have failed with command not found")
|
t.Error("this test should have failed with command not found")
|
||||||
}
|
}
|
||||||
if err := shell.handle("hello"); err != nil {
|
if _, err := shell.handle(shell.ctx, "hello"); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
printedOut := strings.TrimSpace(helloOut.String())
|
printedOut := strings.TrimSpace(helloOut.String())
|
||||||
@@ -62,7 +62,7 @@ func TestShellHandle(t *testing.T) {
|
|||||||
|
|
||||||
byeOut := bytes.NewBufferString("")
|
byeOut := bytes.NewBufferString("")
|
||||||
shell.ctx = context.WithValue(context.TODO(), "gosh.stdout", byeOut)
|
shell.ctx = context.WithValue(context.TODO(), "gosh.stdout", byeOut)
|
||||||
if err := shell.handle("goodbye"); err != nil {
|
if _, err := shell.handle(shell.ctx, "goodbye"); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
printedOut = strings.TrimSpace(byeOut.String())
|
printedOut = strings.TrimSpace(byeOut.String())
|
||||||
Reference in New Issue
Block a user