From dd66646c060761a16c71de6ebde1f24474e9f494 Mon Sep 17 00:00:00 2001 From: Christopher Crone Date: Thu, 21 May 2020 20:03:06 +0200 Subject: [PATCH] Unit test run help Signed-off-by: Christopher Crone --- cli/cmd/run/run_test.go | 42 ++++++++++++++++++++++++++++ cli/cmd/run/testdata/run-help.golden | 10 +++++++ 2 files changed, 52 insertions(+) create mode 100644 cli/cmd/run/run_test.go create mode 100644 cli/cmd/run/testdata/run-help.golden diff --git a/cli/cmd/run/run_test.go b/cli/cmd/run/run_test.go new file mode 100644 index 000000000..d34050d44 --- /dev/null +++ b/cli/cmd/run/run_test.go @@ -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") +} diff --git a/cli/cmd/run/testdata/run-help.golden b/cli/cmd/run/testdata/run-help.golden new file mode 100644 index 000000000..7bdf7de85 --- /dev/null +++ b/cli/cmd/run/testdata/run-help.golden @@ -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