From 62230c7ec293602f63906039deb6c27ce7c5d550 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 13 Oct 2024 17:50:29 +0200 Subject: [PATCH] completion: add test for FromList Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 51713196c9d5312cf98f59ff0a73452dda5049e2) Signed-off-by: Sebastiaan van Stijn --- cli/command/completion/functions_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cli/command/completion/functions_test.go b/cli/command/completion/functions_test.go index d915ccdc36..7a98e2d3c9 100644 --- a/cli/command/completion/functions_test.go +++ b/cli/command/completion/functions_test.go @@ -29,6 +29,14 @@ func TestCompleteFileNames(t *testing.T) { assert.Check(t, is.Len(values, 0)) } +func TestCompleteFromList(t *testing.T) { + expected := []string{"one", "two", "three"} + + values, directives := FromList(expected...)(nil, nil, "") + assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion") + assert.Check(t, is.DeepEqual(values, expected)) +} + func TestCompletePlatforms(t *testing.T) { values, directives := Platforms(nil, nil, "") assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion")