airshipctl/cmd/version_test.go
Ian Howell 1c999e2095 Add coverage checks
This commit adds a makefile target for generating a report for unit test
coverage. It also adds the coverage_check tool to assert that the actual
test coverage meets the specified requirement.

This also improves various aspects of the testing utilities:
* The "test" package has been renamed to "testutil"
* The "Objs" member has been removed from the CmdTest object
* The "Cmd" member has been added to the CmdTest object. This allows
  testing of multiple variants of a root airshipctl command

Finally, this commit includes additional tests for root.go. These are
required in order to meet the required coverage threshold.

Change-Id: Id48343166c0488c543a405ec3143e4a75355ba43
2019-08-15 11:11:51 -05:00

29 lines
499 B
Go

package cmd_test
import (
"testing"
"opendev.org/airship/airshipctl/cmd"
"opendev.org/airship/airshipctl/testutil"
)
func TestVersion(t *testing.T) {
rootCmd, _, err := cmd.NewRootCmd(nil)
if err != nil {
t.Fatalf("Could not create root command: %s", err.Error())
}
rootCmd.AddCommand(cmd.NewVersionCommand())
cmdTests := []*testutil.CmdTest{
{
Name: "version",
CmdLine: "version",
Cmd: rootCmd,
},
}
for _, tt := range cmdTests {
testutil.RunTest(t, tt)
}
}