feat: add pmg config get/set/edit CLI commands (#262)

This commit is contained in:
Sahil Bansal
2026-05-16 09:55:54 +05:30
committed by GitHub
parent 4de9f84c0c
commit c78287e5a0
12 changed files with 781 additions and 24 deletions
+32
View File
@@ -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()