mirror of https://github.com/docker/cli.git
completion: add test for EnvVarNames
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
b8cddc63ad
commit
8f2e5662e7
|
@ -1,13 +1,28 @@
|
||||||
package completion
|
package completion
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
|
"gotest.tools/v3/env"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestCompleteEnvVarNames(t *testing.T) {
|
||||||
|
env.PatchAll(t, map[string]string{
|
||||||
|
"ENV_A": "hello-a",
|
||||||
|
"ENV_B": "hello-b",
|
||||||
|
})
|
||||||
|
values, directives := EnvVarNames(nil, nil, "")
|
||||||
|
assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion")
|
||||||
|
|
||||||
|
sort.Strings(values)
|
||||||
|
expected := []string{"ENV_A", "ENV_B"}
|
||||||
|
assert.Check(t, is.DeepEqual(values, expected))
|
||||||
|
}
|
||||||
|
|
||||||
func TestCompletePlatforms(t *testing.T) {
|
func TestCompletePlatforms(t *testing.T) {
|
||||||
values, directives := Platforms(nil, nil, "")
|
values, directives := Platforms(nil, nil, "")
|
||||||
assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion")
|
assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion")
|
||||||
|
|
Loading…
Reference in New Issue