airshipctl/cmd/completion/completion_test.go
Ian Howell dc9c78b210 Fix the coverage tests
This fixes a bug where `make cover` was missing packages. The target now
covers all code except for code placed in the top level package (such as
main.go) and anything placed in the testutils directory.

This also fixes minor issues with the Dockerfile and the coverage_check
script

Note that this commit also strives to increase code coverage beyond the
80% margin

Change-Id: I9e1cbcf841cc869345a00f05e39774cb3da10065
2019-10-02 15:18:56 -05:00

49 lines
916 B
Go

package completion_test
import (
"errors"
"testing"
"opendev.org/airship/airshipctl/cmd/completion"
"opendev.org/airship/airshipctl/testutil"
)
func TestCompletion(t *testing.T) {
cmd := completion.NewCompletionCommand()
cmdTests := []*testutil.CmdTest{
{
Name: "completion-bash",
CmdLine: "bash",
Cmd: cmd,
},
{
Name: "completion-zsh",
CmdLine: "zsh",
Cmd: cmd,
},
{
Name: "completion-no-args",
CmdLine: "",
Cmd: cmd,
Error: errors.New("shell not specified"),
},
{
Name: "completion-too-many-args",
CmdLine: "bash zsh",
Cmd: cmd,
Error: errors.New("too many arguments, expected only the shell type"),
},
{
Name: "completion-unknown-shell",
CmdLine: "fish",
Cmd: cmd,
Error: errors.New("unsupported shell type \"fish\""),
},
}
for _, tt := range cmdTests {
testutil.RunTest(t, tt)
}
}