Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features

* Add `environment` property to config created with `ForEnvironment` - [#63](https://github.com/ResourceDataInc/Centroid/pull/63)
* Deep merge support - [#56](https://github.com/ResourceDataInc/Centroid/pull/56)
* Add `ContainsKey` method - [#50](https://github.com/ResourceDataInc/Centroid/pull/50)

Expand All @@ -17,6 +18,7 @@

### Features

* Add `environment` property to config created with `for_environment` - [#63](https://github.com/ResourceDataInc/Centroid/pull/63)
* Deep merge support - [#56](https://github.com/ResourceDataInc/Centroid/pull/56)
* Add `__contains__` support - [#50](https://github.com/ResourceDataInc/Centroid/pull/50)

Expand All @@ -28,6 +30,7 @@

### Features

* Add `environment` property to config created with `for_environment` - [#63](https://github.com/ResourceDataInc/Centroid/pull/63)
* Deep merge support - [#56](https://github.com/ResourceDataInc/Centroid/pull/56)
* Add `has_key?` method - [#50](https://github.com/ResourceDataInc/Centroid/pull/50)

Expand Down
8 changes: 8 additions & 0 deletions dot-net/Centroid.Tests/ConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ public void test_readable_using_snake_case_property()
Assert.That(config.the_environment.the_key, Is.EqualTo("TheValue"));
}

[Test]
public void test_environment_property_is_included()
{
var config = new Config(JsonConfig);
dynamic environmentConfig = config.ForEnvironment("theEnvironment");
Assert.That(environmentConfig.environment, Is.EqualTo("theEnvironment"));
}

[Test]
public void test_environment_specific_config_is_included()
{
Expand Down
1 change: 1 addition & 0 deletions dot-net/Centroid/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public bool ContainsKey(string key)
public dynamic ForEnvironment(string environment)
{
var envConfig = GetContainer(environment);
envConfig["environment"] = environment;
var allConfig = GetContainer("all");

if (allConfig == null)
Expand Down
1 change: 1 addition & 0 deletions python/centroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _validate_unique_keys(self):

def for_environment(self, env):
env_json = self.raw_config[env]
env_json["environment"] = env

actual_key = _get_actual_key('all', self.raw_config)
if actual_key is None:
Expand Down
5 changes: 5 additions & 0 deletions python/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def test_readable_using_snake_case_property(self):
config = Config(self._json_config)
self.assertEqual(config.the_environment.the_key, "TheValue")

def test_environment_property_is_included(self):
config = Config(self._json_config)
environment_config = config.for_environment("theEnvironment")
self.assertEqual(environment_config.environment, "theEnvironment")

def test_environment_specific_config_is_included(self):
config = Config(self._json_config)
environment_config = config.for_environment("theEnvironment")
Expand Down
1 change: 1 addition & 0 deletions ruby/lib/centroid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def to_s

def for_environment(env)
env_json = raw_config[env]
env_json["environment"] = env
all_key = actual_key("all")
if all_key.nil?
Config.new(env_json)
Expand Down
6 changes: 6 additions & 0 deletions ruby/test/centroid_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def test_readable_using_snake_case_property
assert_equal(config.the_environment.the_key, "TheValue")
end

def test_environment_property_is_included
config = Centroid::Config.new(json_config)
environment_config = config.for_environment("theEnvironment")
assert_equal(environment_config.environment, "theEnvironment")
end

def test_environment_specific_config_is_included
config = Centroid::Config.new(json_config)
environment_config = config.for_environment("theEnvironment")
Expand Down