Increase code coverage

This adds coverage to:

* NewDocumentCommand
* NewBaremetalCommand

Change-Id: I7ece84cd36a4df07dc4c2e7437175484ced9b802
This commit is contained in:
Ian Howell 2020-04-28 13:45:27 -05:00
parent da5d62b95a
commit 95a768e366
14 changed files with 89 additions and 20 deletions

View File

@ -24,12 +24,17 @@ import (
func TestBaremetal(t *testing.T) {
tests := []*testutil.CmdTest{
{
Name: "isogen",
Name: "baremetal-with-help",
CmdLine: "-h",
Cmd: baremetal.NewBaremetalCommand(nil),
},
{
Name: "baremetal-isogen-with-help",
CmdLine: "-h",
Cmd: baremetal.NewISOGenCommand(nil),
},
{
Name: "remotedirect",
Name: "baremetal-remotedirect-with-help",
CmdLine: "-h",
Cmd: baremetal.NewRemoteDirectCommand(nil),
},

View File

@ -0,0 +1,14 @@
Perform actions on baremetal hosts
Usage:
baremetal [command]
Available Commands:
help Help about any command
isogen Generate baremetal host ISO image
remotedirect Bootstrap the ephemeral host
Flags:
-h, --help help for baremetal
Use "baremetal [command] --help" for more information about a command.

View File

@ -23,11 +23,26 @@ import (
func TestDocument(t *testing.T) {
tests := []*testutil.CmdTest{
{
Name: "document-with-help",
CmdLine: "-h",
Cmd: document.NewDocumentCommand(nil),
},
{
Name: "document-render-with-help",
CmdLine: "-h",
Cmd: document.NewRenderCommand(nil),
},
{
Name: "document-plugin-with-help",
CmdLine: "-h",
Cmd: document.NewPluginCommand(nil),
},
{
Name: "document-pull-with-help",
CmdLine: "-h",
Cmd: document.NewPluginCommand(nil),
},
}
for _, tt := range tests {
testutil.RunTest(t, tt)

View File

@ -23,11 +23,6 @@ import (
func TestPlugin(t *testing.T) {
cmdTests := []*testutil.CmdTest{
{
Name: "document-plugin-cmd-with-help",
CmdLine: "--help",
Cmd: NewPluginCommand(nil),
},
{
Name: "document-plugin-cmd-with-empty-args",
CmdLine: "",

View File

@ -48,15 +48,10 @@ func getDummyAirshipSettings() *environment.AirshipCTLSettings {
func TestPull(t *testing.T) {
cmdTests := []*testutil.CmdTest{
{
Name: "document-pull-cmd-with-defaults",
Name: "document-pull-cmd",
CmdLine: "",
Cmd: NewPullCommand(getDummyAirshipSettings()),
},
{
Name: "document-pull-cmd-with-help",
CmdLine: "--help",
Cmd: NewPullCommand(nil),
},
}
for _, tt := range cmdTests {

View File

@ -0,0 +1,37 @@
This command is meant to be used as a kustomize exec plugin.
The command reads the configuration file CONFIG passed as a first argument and
determines a particular plugin to execute. Additional arguments may be passed
to this command and can be used by the particular plugin.
CONFIG must be a structured kubernetes manifest (i.e. resource) and must have
'apiVersion' and 'kind' keys. If the appropriate plugin was not found, the
command returns an error.
Usage:
plugin CONFIG [ARGS] [flags]
Examples:
# Perform a replacement on a deployment. Prior to running this command,
# the file '/tmp/replacement.yaml' should be created as follows:
---
apiVersion: airshipit.org/v1alpha1
kind: ReplacementTransformer
metadata:
name: notImportantHere
replacements:
- source:
value: nginx:newtag
target:
objref:
kind: Deployment
fieldrefs:
- spec.template.spec.containers[name=nginx-latest].image
# The replacement can then be performed. Output defaults to stdout.
airshipctl document plugin /tmp/replacement.yaml
Flags:
-h, --help help for plugin

View File

@ -0,0 +1,15 @@
Manage deployment documents
Usage:
document [command]
Available Commands:
help Help about any command
plugin Run as a kustomize exec plugin
pull Pulls documents from remote git repository
render Render documents from model
Flags:
-h, --help help for document
Use "document [command] --help" for more information about a command.

View File

@ -1,7 +0,0 @@
Pulls documents from remote git repository
Usage:
pull [flags]
Flags:
-h, --help help for pull