mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-05 21:21:42 +00:00
Engine: builtin command 'commands' returns a list of registered commands
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
@@ -63,6 +64,24 @@ func TestJob(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineCommands(t *testing.T) {
|
||||
eng := newTestEngine(t)
|
||||
defer os.RemoveAll(eng.Root())
|
||||
handler := func(job *Job) Status { return StatusOK }
|
||||
eng.Register("foo", handler)
|
||||
eng.Register("bar", handler)
|
||||
eng.Register("echo", handler)
|
||||
eng.Register("die", handler)
|
||||
var output bytes.Buffer
|
||||
commands := eng.Job("commands")
|
||||
commands.Stdout.Add(&output)
|
||||
commands.Run()
|
||||
expected := "bar\ncommands\ndie\necho\nfoo\n"
|
||||
if result := output.String(); result != expected {
|
||||
t.Fatalf("Unexpected output:\nExpected = %v\nResult = %v\n", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineRoot(t *testing.T) {
|
||||
tmp, err := ioutil.TempDir("", "docker-test-TestEngineCreateDir")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user