2026-01-01 12:33:52 +05:30
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-04-17 01:13:30 +05:30
|
|
|
"github.com/spf13/cobra"
|
2026-01-01 12:33:52 +05:30
|
|
|
"github.com/stretchr/testify/assert"
|
2026-03-31 19:21:01 +05:30
|
|
|
"github.com/stretchr/testify/require"
|
2026-01-01 12:33:52 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestConfigIsNeverNil(t *testing.T) {
|
|
|
|
|
config := Get()
|
|
|
|
|
assert.NotNil(t, config)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestConfigHasDefaultValues(t *testing.T) {
|
|
|
|
|
t.Run("with non-existent config directory", func(t *testing.T) {
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", "/tmp/pmg-test/random-does-not-exist")
|
|
|
|
|
initConfig()
|
|
|
|
|
|
|
|
|
|
config := Get()
|
|
|
|
|
assert.Equal(t, false, config.Config.Paranoid)
|
2026-04-17 01:13:30 +05:30
|
|
|
assert.Len(t, config.Config.TrustedPackages, 1)
|
2026-01-01 12:33:52 +05:30
|
|
|
assert.Equal(t, "/tmp/pmg-test/random-does-not-exist", config.configDir)
|
|
|
|
|
assert.Equal(t, "/tmp/pmg-test/random-does-not-exist/config.yml", config.configFilePath)
|
2026-05-06 18:27:23 +05:30
|
|
|
assert.Equal(t, false, config.Config.Proxy.InstallOnly)
|
2026-01-01 12:33:52 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("when no config directory is set", func(t *testing.T) {
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", "")
|
|
|
|
|
initConfig()
|
|
|
|
|
|
|
|
|
|
config := Get()
|
|
|
|
|
|
|
|
|
|
userConfigDir, err := os.UserConfigDir()
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, filepath.Join(userConfigDir, "safedep/pmg"), config.configDir)
|
|
|
|
|
assert.Equal(t, filepath.Join(userConfigDir, "safedep/pmg/config.yml"), config.configFilePath)
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-03-31 19:21:01 +05:30
|
|
|
|
2026-04-08 21:04:17 +05:30
|
|
|
func TestPartialConfigFallsBackToDefaults(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
|
|
|
|
|
|
|
|
|
// Write a minimal config that only sets a couple of fields,
|
|
|
|
|
// simulating a user who upgraded PMG without re-running setup
|
2026-07-22 15:19:19 +05:30
|
|
|
partialConfig := []byte("skip_event_logging: true\nparanoid: true\n")
|
2026-04-08 21:04:17 +05:30
|
|
|
err := os.WriteFile(configPath, partialConfig, 0o644)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
|
|
|
|
config := Get()
|
|
|
|
|
|
|
|
|
|
// Explicitly set values should be respected
|
2026-07-22 15:19:19 +05:30
|
|
|
assert.Equal(t, true, config.Config.SkipEventLogging)
|
2026-04-08 21:04:17 +05:30
|
|
|
assert.Equal(t, true, config.Config.Paranoid)
|
|
|
|
|
|
|
|
|
|
// Missing keys should fall back to DefaultConfig() values, not Go zero values
|
|
|
|
|
defaults := DefaultConfig().Config
|
|
|
|
|
assert.Equal(t, defaults.Verbosity, config.Config.Verbosity)
|
|
|
|
|
assert.Equal(t, defaults.EventLogRetentionDays, config.Config.EventLogRetentionDays)
|
|
|
|
|
assert.Equal(t, defaults.DependencyCooldown.Enabled, config.Config.DependencyCooldown.Enabled)
|
|
|
|
|
assert.Equal(t, defaults.DependencyCooldown.Days, config.Config.DependencyCooldown.Days)
|
|
|
|
|
assert.Equal(t, defaults.Sandbox.Enabled, config.Config.Sandbox.Enabled)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPartialConfigWithNestedOverride(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
|
|
|
|
|
|
|
|
|
// Override only one nested field; other nested and top-level fields should keep defaults
|
|
|
|
|
partialConfig := []byte("dependency_cooldown:\n days: 10\n")
|
|
|
|
|
err := os.WriteFile(configPath, partialConfig, 0o644)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
|
|
|
|
config := Get()
|
|
|
|
|
|
|
|
|
|
defaults := DefaultConfig().Config
|
|
|
|
|
|
|
|
|
|
// Explicitly set nested value should be respected
|
|
|
|
|
assert.Equal(t, 10, config.Config.DependencyCooldown.Days)
|
|
|
|
|
|
|
|
|
|
// Sibling nested field should fall back to default
|
|
|
|
|
assert.Equal(t, defaults.DependencyCooldown.Enabled, config.Config.DependencyCooldown.Enabled)
|
|
|
|
|
|
|
|
|
|
// Top-level fields should fall back to defaults
|
2026-07-22 15:19:19 +05:30
|
|
|
assert.Equal(t, defaults.Paranoid, config.Config.Paranoid)
|
|
|
|
|
assert.Equal(t, defaults.EventLogRetentionDays, config.Config.EventLogRetentionDays)
|
2026-04-08 21:04:17 +05:30
|
|
|
}
|
|
|
|
|
|
2026-04-17 01:13:30 +05:30
|
|
|
func TestProxyInstallOnlyConfig(t *testing.T) {
|
|
|
|
|
t.Run("defaults to false", func(t *testing.T) {
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", "/tmp/pmg-test/random-does-not-exist")
|
|
|
|
|
initConfig()
|
2026-05-06 18:27:23 +05:30
|
|
|
assert.Equal(t, false, Get().Config.Proxy.InstallOnly)
|
2026-04-17 01:13:30 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("can be set to true via config file", func(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
2026-05-06 18:27:23 +05:30
|
|
|
err := os.WriteFile(configPath, []byte("proxy:\n install_only: true\n"), 0o644)
|
2026-04-17 01:13:30 +05:30
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
2026-05-06 18:27:23 +05:30
|
|
|
assert.Equal(t, true, Get().Config.Proxy.InstallOnly)
|
2026-04-17 01:13:30 +05:30
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TestConfigPrecedence verifies the expected override order:
|
|
|
|
|
// flags > env var > config file > default
|
|
|
|
|
func TestConfigPrecedence(t *testing.T) {
|
2026-05-06 18:27:23 +05:30
|
|
|
t.Run("env var sets legacy flat field", func(t *testing.T) {
|
2026-04-17 01:13:30 +05:30
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
t.Setenv("PMG_PROXY_INSTALL_ONLY", "true")
|
|
|
|
|
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
|
|
|
|
err := os.WriteFile(configPath, []byte("proxy_install_only: false\n"), 0o644)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
2026-05-06 18:27:23 +05:30
|
|
|
// PMG_PROXY_INSTALL_ONLY maps to the flat proxy_install_only key, not nested proxy.install_only
|
|
|
|
|
assert.Equal(t, true, Get().Config.ProxyInstallOnly, "env var should set legacy flat field")
|
2026-04-17 01:13:30 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("config file overrides default", func(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
t.Setenv("PMG_PROXY_INSTALL_ONLY", "")
|
|
|
|
|
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
2026-05-06 18:27:23 +05:30
|
|
|
err := os.WriteFile(configPath, []byte("proxy:\n install_only: true\n"), 0o644)
|
2026-04-17 01:13:30 +05:30
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
2026-05-06 18:27:23 +05:30
|
|
|
assert.Equal(t, true, Get().Config.Proxy.InstallOnly, "config file should override default")
|
2026-04-17 01:13:30 +05:30
|
|
|
})
|
|
|
|
|
|
2026-04-22 22:04:56 +05:30
|
|
|
t.Run("telemetry can be disabled via config", func(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
t.Setenv("PMG_DISABLE_TELEMETRY", "")
|
|
|
|
|
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
|
|
|
|
err := os.WriteFile(configPath, []byte("disable_telemetry: true\n"), 0o644)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
|
|
|
|
assert.Equal(t, true, Get().Config.DisableTelemetry, "config file should disable telemetry")
|
|
|
|
|
})
|
|
|
|
|
|
2026-04-17 01:13:30 +05:30
|
|
|
t.Run("env var works without a config file", func(t *testing.T) {
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", "/tmp/pmg-test/random-does-not-exist")
|
2026-05-06 18:27:23 +05:30
|
|
|
t.Setenv("PMG_PARANOID", "true")
|
2026-04-17 01:13:30 +05:30
|
|
|
|
|
|
|
|
initConfig()
|
2026-05-06 18:27:23 +05:30
|
|
|
assert.Equal(t, true, Get().Config.Paranoid, "env var should work even without a config file")
|
2026-04-17 01:13:30 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("default is used when neither env var nor config file sets the key", func(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
t.Setenv("PMG_PROXY_INSTALL_ONLY", "")
|
|
|
|
|
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
2026-07-22 15:19:19 +05:30
|
|
|
err := os.WriteFile(configPath, []byte("paranoid: false\n"), 0o644)
|
2026-04-17 01:13:30 +05:30
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
2026-05-06 18:27:23 +05:30
|
|
|
assert.Equal(t, false, Get().Config.Proxy.InstallOnly, "should use default when key absent from config and env")
|
|
|
|
|
assert.Equal(t, false, Get().Config.ProxyInstallOnly, "legacy flat field should also default to false")
|
2026-04-17 01:13:30 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("cobra flag overrides env var", func(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
t.Setenv("PMG_PARANOID", "true")
|
|
|
|
|
|
|
|
|
|
initConfig()
|
|
|
|
|
assert.Equal(t, true, Get().Config.Paranoid, "env var should set paranoid=true")
|
|
|
|
|
|
|
|
|
|
// Simulate cobra flag parsing — BoolVar writes directly to the struct
|
|
|
|
|
// field after Viper, giving flags the highest effective precedence.
|
|
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
ApplyCobraFlags(cmd)
|
|
|
|
|
require.NoError(t, cmd.ParseFlags([]string{"--paranoid=false"}))
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, false, Get().Config.Paranoid, "cobra flag should override env var")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-28 17:49:58 +05:30
|
|
|
func TestConfigureSandbox(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
sandboxEnabled bool
|
|
|
|
|
enforceAlways bool
|
|
|
|
|
mayDownloadPackages bool
|
|
|
|
|
expectedSandboxState bool
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "sandbox disabled stays disabled regardless of command",
|
|
|
|
|
sandboxEnabled: false,
|
|
|
|
|
mayDownloadPackages: true,
|
|
|
|
|
expectedSandboxState: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "sandbox enabled with download command stays enabled",
|
|
|
|
|
sandboxEnabled: true,
|
|
|
|
|
mayDownloadPackages: true,
|
|
|
|
|
expectedSandboxState: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "sandbox enabled with non-download command gets disabled",
|
|
|
|
|
sandboxEnabled: true,
|
|
|
|
|
mayDownloadPackages: false,
|
|
|
|
|
expectedSandboxState: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "enforce_always keeps sandbox enabled for non-download command",
|
|
|
|
|
sandboxEnabled: true,
|
|
|
|
|
enforceAlways: true,
|
|
|
|
|
mayDownloadPackages: false,
|
|
|
|
|
expectedSandboxState: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "enforce_always with download command stays enabled",
|
|
|
|
|
sandboxEnabled: true,
|
|
|
|
|
enforceAlways: true,
|
|
|
|
|
mayDownloadPackages: true,
|
|
|
|
|
expectedSandboxState: true,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tc := range tests {
|
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", "/tmp/pmg-test/random-does-not-exist")
|
|
|
|
|
initConfig()
|
|
|
|
|
|
|
|
|
|
cfg := Get()
|
|
|
|
|
cfg.Config.Sandbox.Enabled = tc.sandboxEnabled
|
|
|
|
|
cfg.Config.Sandbox.EnforceAlways = tc.enforceAlways
|
|
|
|
|
|
|
|
|
|
ConfigureSandbox(tc.mayDownloadPackages)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, tc.expectedSandboxState, cfg.Config.Sandbox.Enabled)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-22 10:12:02 +05:30
|
|
|
func TestLocalDBLocation(t *testing.T) {
|
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CACHE_DIR", dir)
|
|
|
|
|
initConfig()
|
|
|
|
|
|
|
|
|
|
cfg := Get()
|
|
|
|
|
assert.Equal(t, filepath.Join(dir, "localdb"), cfg.LocalDBDir())
|
|
|
|
|
assert.Equal(t, "pmg.db", cfg.LocalDBFileName())
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 19:21:01 +05:30
|
|
|
func TestWriteTemplateConfigMergesExistingConfig(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
|
|
|
|
|
|
|
|
|
// Write a partial user config
|
2026-07-22 15:19:19 +05:30
|
|
|
userConfig := []byte("paranoid: true\nevent_log_retention_days: 10\n")
|
2026-03-31 19:21:01 +05:30
|
|
|
err := os.WriteFile(configPath, userConfig, 0o644)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
// Re-init so paths point to tmpDir
|
|
|
|
|
initConfig()
|
|
|
|
|
|
|
|
|
|
// Run WriteTemplateConfig — should merge, not skip
|
|
|
|
|
err = WriteTemplateConfig()
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
// Read back
|
|
|
|
|
result, err := os.ReadFile(configPath)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
raw := string(result)
|
|
|
|
|
|
|
|
|
|
// User values preserved
|
2026-07-22 15:19:19 +05:30
|
|
|
assert.Contains(t, raw, "paranoid: true")
|
|
|
|
|
assert.Contains(t, raw, "event_log_retention_days: 10")
|
2026-03-31 19:21:01 +05:30
|
|
|
|
|
|
|
|
// New keys from template added
|
2026-05-06 18:27:23 +05:30
|
|
|
assert.Contains(t, raw, "proxy:")
|
2026-03-31 19:21:01 +05:30
|
|
|
assert.Contains(t, raw, "sandbox:")
|
|
|
|
|
assert.Contains(t, raw, "verbosity:")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestWriteTemplateConfigCreatesNewFile(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
|
|
|
|
|
|
|
|
|
err := WriteTemplateConfig()
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
|
|
|
|
result, err := os.ReadFile(configPath)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
// Should be the full template
|
|
|
|
|
assert.Equal(t, templateConfig, string(result))
|
|
|
|
|
}
|
2026-05-06 18:27:23 +05:30
|
|
|
|
|
|
|
|
func TestProxyConfigSection(t *testing.T) {
|
2026-07-22 15:19:19 +05:30
|
|
|
t.Run("defaults to install_only false", func(t *testing.T) {
|
2026-05-06 18:27:23 +05:30
|
|
|
t.Setenv("PMG_CONFIG_DIR", "/tmp/pmg-test/random-does-not-exist")
|
|
|
|
|
initConfig()
|
|
|
|
|
|
|
|
|
|
cfg := Get()
|
|
|
|
|
assert.Equal(t, false, cfg.Config.Proxy.InstallOnly)
|
2026-05-06 19:26:39 +05:30
|
|
|
assert.NotNil(t, cfg.Config.Proxy.SkipCommands)
|
2026-05-06 18:27:23 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("reads proxy section from config file", func(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
|
|
|
|
|
configYAML := `proxy:
|
|
|
|
|
install_only: true
|
2026-05-06 19:26:39 +05:30
|
|
|
skip_commands:
|
|
|
|
|
npm: ["my-script", "dev"]
|
2026-05-06 18:27:23 +05:30
|
|
|
`
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
|
|
|
|
err := os.WriteFile(configPath, []byte(configYAML), 0o644)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
|
|
|
|
cfg := Get()
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, true, cfg.Config.Proxy.InstallOnly)
|
2026-05-06 19:26:39 +05:30
|
|
|
assert.Equal(t, []string{"my-script", "dev"}, cfg.Config.Proxy.SkipCommands["npm"])
|
2026-05-06 18:27:23 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("falls back to legacy keys from config file", func(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
|
2026-07-22 15:19:19 +05:30
|
|
|
configYAML := `proxy_install_only: true
|
2026-05-06 18:27:23 +05:30
|
|
|
`
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
|
|
|
|
err := os.WriteFile(configPath, []byte(configYAML), 0o644)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
|
|
|
|
cfg := Get()
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, true, cfg.Config.Proxy.InstallOnly)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("falls back to legacy keys from env vars", func(t *testing.T) {
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", "/tmp/pmg-test/random-does-not-exist")
|
|
|
|
|
t.Setenv("PMG_PROXY_INSTALL_ONLY", "true")
|
|
|
|
|
|
|
|
|
|
initConfig()
|
|
|
|
|
cfg := Get()
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, true, cfg.Config.Proxy.InstallOnly, "PMG_PROXY_INSTALL_ONLY=true should set Proxy.InstallOnly=true")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("new proxy section takes precedence over old keys", func(t *testing.T) {
|
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
|
t.Setenv("PMG_CONFIG_DIR", tmpDir)
|
|
|
|
|
|
2026-07-22 15:19:19 +05:30
|
|
|
configYAML := `proxy_install_only: true
|
2026-05-06 18:27:23 +05:30
|
|
|
proxy:
|
|
|
|
|
install_only: false
|
|
|
|
|
`
|
|
|
|
|
configPath := filepath.Join(tmpDir, "config.yml")
|
|
|
|
|
err := os.WriteFile(configPath, []byte(configYAML), 0o644)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
initConfig()
|
|
|
|
|
cfg := Get()
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, false, cfg.Config.Proxy.InstallOnly, "new proxy.install_only should win over old proxy_install_only")
|
|
|
|
|
})
|
|
|
|
|
}
|