mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
feat: add pmg config get/set/edit CLI commands (#262)
This commit is contained in:
@@ -9,6 +9,38 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestLegacyProxyFallbackSyncsToViper(t *testing.T) {
|
||||
t.Run("proxy_mode synced to viper for GetConfigValue", func(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
||||
|
||||
configPath := filepath.Join(tmpDir, "config.yml")
|
||||
err := os.WriteFile(configPath, []byte("proxy_mode: false\n"), 0o644)
|
||||
require.NoError(t, err)
|
||||
|
||||
initConfig()
|
||||
|
||||
val, err := GetConfigValue("proxy.enabled")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, false, val)
|
||||
})
|
||||
|
||||
t.Run("proxy_install_only synced to viper for GetConfigValue", func(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
||||
|
||||
configPath := filepath.Join(tmpDir, "config.yml")
|
||||
err := os.WriteFile(configPath, []byte("proxy_install_only: true\n"), 0o644)
|
||||
require.NoError(t, err)
|
||||
|
||||
initConfig()
|
||||
|
||||
val, err := GetConfigValue("proxy.install_only")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, val)
|
||||
})
|
||||
}
|
||||
|
||||
func TestNewEnvVarNotOverriddenByLegacyConfigFile(t *testing.T) {
|
||||
t.Run("PMG_PROXY_ENABLED wins over proxy_mode in config file", func(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user