From 8383b2832290dc969f2924a1c552852159bbaeed Mon Sep 17 00:00:00 2001 From: koba1t Date: Thu, 25 May 2023 04:25:10 +0900 Subject: [PATCH] fix test case handling and update a function comment --- kustomize/commands/internal/util/util.go | 4 ++-- kustomize/commands/internal/util/util_test.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kustomize/commands/internal/util/util.go b/kustomize/commands/internal/util/util.go index d68a6edca..94004e997 100644 --- a/kustomize/commands/internal/util/util.go +++ b/kustomize/commands/internal/util/util.go @@ -30,8 +30,8 @@ func GlobPatterns(fSys filesys.FileSystem, patterns []string) ([]string, error) return result, nil } -// GlobPatterns accepts a slice of glob strings and returns the set of -// matching file paths. If files are not found, will try load from remote. +// GlobPatterns accepts a slice of glob strings and returns the set of matching file paths. If files are not found, will try load from remote. +// It returns an error if there are no matching files or it can't load from remote. func GlobPatternsWithLoader(fSys filesys.FileSystem, ldr ifc.Loader, patterns []string) ([]string, error) { var result []string for _, pattern := range patterns { diff --git a/kustomize/commands/internal/util/util_test.go b/kustomize/commands/internal/util/util_test.go index 20d0b030a..631e1145f 100644 --- a/kustomize/commands/internal/util/util_test.go +++ b/kustomize/commands/internal/util/util_test.go @@ -91,7 +91,9 @@ func TestGlobPatternsWithLoaderRemoteFile(t *testing.T) { // test load invalid file invalidURL := "http://invalid" resources, err = GlobPatternsWithLoader(fSys, ldr, []string{invalidURL}) - if err != nil && err.Error() != invalidURL+" has no match: "+invalidURL+" not exist" { + if err == nil { + t.Fatalf("expected error but did not receive one") + } else if err.Error() != invalidURL+" has no match: "+invalidURL+" not exist" { t.Fatalf("unexpected load error: %v", err) } if len(resources) > 0 {