From 40725aea3c0f3a126c2583843ebf8e779947a4d5 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 18 Mar 2025 11:41:33 +0100 Subject: [PATCH] cli-plugins/manager: add test for empty / non-existing plugin dirs Verify that listPluginCandidates returns an empty result if nothing was found. Signed-off-by: Sebastiaan van Stijn --- cli-plugins/manager/manager_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cli-plugins/manager/manager_test.go b/cli-plugins/manager/manager_test.go index 92cbd002d4..6551865a9d 100644 --- a/cli-plugins/manager/manager_test.go +++ b/cli-plugins/manager/manager_test.go @@ -1,6 +1,7 @@ package manager import ( + "path/filepath" "strings" "testing" @@ -81,6 +82,12 @@ func TestListPluginCandidates(t *testing.T) { assert.DeepEqual(t, candidates, exp) } +func TestListPluginCandidatesEmpty(t *testing.T) { + tmpDir := t.TempDir() + candidates := listPluginCandidates([]string{tmpDir, filepath.Join(tmpDir, "no-such-dir")}) + assert.Assert(t, len(candidates) == 0) +} + // Regression test for https://github.com/docker/cli/issues/5643. // Check that inaccessible directories that come before accessible ones are ignored // and do not prevent the latter from being processed.