mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-17 01:39:06 +00:00
Move plugin config to main config package.
This commit is contained in:
43
api/pgmconfig/pluginconfig_test.go
Normal file
43
api/pgmconfig/pluginconfig_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package pgmconfig
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfigDirNoXdg(t *testing.T) {
|
||||
xdg, isSet := os.LookupEnv(XdgConfigHomeEnv)
|
||||
if isSet {
|
||||
os.Unsetenv(XdgConfigHomeEnv)
|
||||
}
|
||||
s := configRoot()
|
||||
if isSet {
|
||||
os.Setenv(XdgConfigHomeEnv, xdg)
|
||||
}
|
||||
if !strings.HasSuffix(
|
||||
s,
|
||||
rootedPath(XdgConfigHomeEnvDefault, ProgramName)) {
|
||||
t.Fatalf("unexpected config dir: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
func rootedPath(elem ...string) string {
|
||||
return string(filepath.Separator) + filepath.Join(elem...)
|
||||
}
|
||||
|
||||
func TestConfigDirWithXdg(t *testing.T) {
|
||||
xdg, isSet := os.LookupEnv(XdgConfigHomeEnv)
|
||||
os.Setenv(XdgConfigHomeEnv, rootedPath("blah"))
|
||||
s := configRoot()
|
||||
if isSet {
|
||||
os.Setenv(XdgConfigHomeEnv, xdg)
|
||||
}
|
||||
if s != rootedPath("blah", ProgramName) {
|
||||
t.Fatalf("unexpected config dir: %s", s)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user