Stabilize the logic for setting-alias conflicts [#66]

This includes a refactor to the way aliases are processed. I had been
thinking in terms of locking down the aliases names pretty tightly, in
order to provide an error if there are conflicts. After discussion with
@josmo, though, it seems like we can do it the same way we do for
"PLUGIN_"/non-prefixed variables, i.e. quietly override them.
This commit is contained in:
Erin Call
2020-01-08 09:31:22 -08:00
parent 1d1117ba49
commit 6aa1d79d56
2 changed files with 36 additions and 37 deletions

View File

@@ -105,6 +105,16 @@ func (suite *ConfigTestSuite) TestNewConfigWithAliases() {
suite.Equal("d2l0aCBpdHMgaGVhZA==", cfg.Certificate, "Certificate should be aliased")
}
func (suite *ConfigTestSuite) TestNewConfigWithAliasConflicts() {
suite.unsetenv("FORCE")
suite.setenv("PLUGIN_FORCE_UPGRADE", "true")
suite.setenv("PLUGIN_FORCE", "false") // should override even when set to the zero value
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
suite.NoError(err)
suite.False(cfg.Force, "official names should override alias names")
}
func (suite *ConfigTestSuite) TestNewConfigSetsWriters() {
stdout := &strings.Builder{}
stderr := &strings.Builder{}