Unit test run help

Signed-off-by: Christopher Crone <christopher.crone@docker.com>
This commit is contained in:
Christopher Crone 2020-05-21 20:03:06 +02:00
parent 0efa67f7d2
commit dd66646c06
2 changed files with 52 additions and 0 deletions

42
cli/cmd/run/run_test.go Normal file
View File

@ -0,0 +1,42 @@
/*
Copyright (c) 2020 Docker Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package run
import (
"bytes"
"testing"
"gotest.tools/v3/golden"
)
func TestHelp(t *testing.T) {
var b bytes.Buffer
c := Command()
c.SetOutput(&b)
_ = c.Help()
golden.Assert(t, b.String(), "run-help.golden")
}

10
cli/cmd/run/testdata/run-help.golden vendored Normal file
View File

@ -0,0 +1,10 @@
Run a container
Usage:
run [flags]
Flags:
-l, --label stringArray Set meta data on a container
--name string Assign a name to the container
-p, --publish stringArray Publish a container's port(s). [HOST_PORT:]CONTAINER_PORT
-v, --volume stringArray Volume. Ex: user:key@my_share:/absolute/path/to/target