Skip to content

Commit 6ccbc0f

Browse files
committed
test: increase coverage
1 parent 2e0a0fb commit 6ccbc0f

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

pkg/cli/options_test.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,32 @@ var _ = Describe("Discover external plugins", func() {
252252
Expect(err.Error()).To(ContainSubstring("host not supported"))
253253
})
254254

255-
It("should return full path to the external plugins", func() {
255+
It("should return full path to the external plugins without XDG_CONFIG_HOME", func() {
256+
if _, ok := os.LookupEnv("XDG_CONFIG_HOME"); ok {
257+
err = os.Setenv("XDG_CONFIG_HOME", "")
258+
Expect(err).To(BeNil())
259+
}
260+
261+
home := os.Getenv("HOME")
262+
263+
pluginsRoot, err := getPluginsRoot("darwin")
264+
Expect(err).To(BeNil())
265+
expected := filepath.Join(home, "Library", "Application Support", "kubebuilder", "plugins")
266+
Expect(pluginsRoot).To(Equal(expected))
267+
268+
pluginsRoot, err = getPluginsRoot("linux")
269+
Expect(err).To(BeNil())
270+
expected = filepath.Join(home, ".config", "kubebuilder", "plugins")
271+
Expect(pluginsRoot).To(Equal(expected))
272+
})
273+
274+
It("should return full path to the external plugins with XDG_CONFIG_HOME", func() {
256275
err = os.Setenv("XDG_CONFIG_HOME", "/some/random/path")
257276
Expect(err).To(BeNil())
258277

259278
pluginsRoot, err := getPluginsRoot(runtime.GOOS)
260279
Expect(err).To(BeNil())
261280
Expect(pluginsRoot).To(Equal("/some/random/path/kubebuilder/plugins"))
262-
263281
})
264282

265283
It("should return error when home directory is set to empty", func() {

pkg/cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const (
3030
)
3131

3232
var (
33-
supportedPlatforms = []string{"linux", "darwin"}
33+
supportedPlatforms = []string{"darwin", "linux"}
3434
)
3535

3636
func (c CLI) newRootCmd() *cobra.Command {

0 commit comments

Comments
 (0)