From 5cc7b38cb9c2d8e23ad5a9863747bb9574b54c71 Mon Sep 17 00:00:00 2001 From: Nataly Shrits Date: Wed, 3 Apr 2019 11:09:12 +0300 Subject: [PATCH] rename propagateErrors -> includeErrors --- ...-errors.test.js => include-errors.test.js} | 38 +++++++++---------- .../Controllers/KeysController.cs | 10 ++--- ...pagate_errors.jpad => include_errors.jpad} | 0 ...pagate_errors.json => include_errors.json} | 4 +- 4 files changed, 24 insertions(+), 28 deletions(-) rename e2e/integration/spec/tweek-api/values/{propagate-errors.test.js => include-errors.test.js} (63%) rename services/git-service/BareRepository/tests-source/implementations/jpad/integration_tests/{propagate_errors.jpad => include_errors.jpad} (100%) rename services/git-service/BareRepository/tests-source/manifests/integration_tests/{propagate_errors.json => include_errors.json} (68%) diff --git a/e2e/integration/spec/tweek-api/values/propagate-errors.test.js b/e2e/integration/spec/tweek-api/values/include-errors.test.js similarity index 63% rename from e2e/integration/spec/tweek-api/values/propagate-errors.test.js rename to e2e/integration/spec/tweek-api/values/include-errors.test.js index d140d5689..2f6d141b3 100644 --- a/e2e/integration/spec/tweek-api/values/propagate-errors.test.js +++ b/e2e/integration/spec/tweek-api/values/include-errors.test.js @@ -4,7 +4,7 @@ const client = require('../../../utils/client'); describe('tweek api - propagate errors', () => { const identityType = 'user'; const identityId = 'bad_context_user'; - const url = `/api/v2/values/integration_tests/propagate_errors`; + const url = `/api/v2/values/integration_tests/include_errors`; before(async () => { await client @@ -13,23 +13,23 @@ describe('tweek api - propagate errors', () => { .expect(200); }); - describe('[propagateErrors = true]', () => { + describe('[includeErrors = true]', () => { it('should return null on single key error', async () => { const result = await client - .get(`${url}?${identityType}=${identityId}&$propagateErrors=true`) + .get(`${url}?${identityType}=${identityId}&$includeErrors=true`) .expect('X-Error-Count', '1') .expect(200); expect(result.body).to.eql({ data: null, errors: { - 'integration_tests/propagate_errors': 'non matching types', + 'integration_tests/include_errors': 'non matching types', }, }); }); it('should return correct value if no error', async () => { const result = await client - .get(`${url}?$propagateErrors=true`) + .get(`${url}?$includeErrors=true`) .expect('X-Error-Count', '0') .expect(200); expect(result.body).to.eql({ data: 'DefaultValue', errors: {} }); @@ -37,33 +37,31 @@ describe('tweek api - propagate errors', () => { it('should skip error key on scan', async () => { const result = await client - .get( - `/api/v2/values/integration_tests/_?${identityType}=${identityId}&$propagateErrors=true`, - ) + .get(`/api/v2/values/integration_tests/_?${identityType}=${identityId}&$includeErrors=true`) .expect('X-Error-Count', '1') .expect(200); - expect(result.body.data).to.not.have.property('propagate_errors'); + expect(result.body.data).to.not.have.property('include_errors'); expect(result.body.errors).to.eql({ - 'integration_tests/propagate_errors': 'non matching types', + 'integration_tests/include_errors': 'non matching types', }); }); it('should return correct value if no error in scan', async () => { const result = await client - .get(`/api/v2/values/integration_tests/_?$propagateErrors=true`) + .get(`/api/v2/values/integration_tests/_?$includeErrors=true`) .expect('X-Error-Count', '0') .expect(200); - expect(result.body.data).to.deep.include({ propagate_errors: 'DefaultValue' }); + expect(result.body.data).to.deep.include({ include_errors: 'DefaultValue' }); expect(result.body.errors).to.eql({}); }); }); - describe('[propagateErrors = false]', () => { + describe('[includeErrors = false]', () => { it('should return null on single key error', async () => { const result = await client - .get(`${url}?${identityType}=${identityId}&$propagateErrors=false`) + .get(`${url}?${identityType}=${identityId}&$includeErrors=false`) .expect('X-Error-Count', '1') .expect(200); expect(result.body).to.eql(null); @@ -71,7 +69,7 @@ describe('tweek api - propagate errors', () => { it('should return correct value if no error', async () => { const result = await client - .get(`${url}?$propagateErrors=false`) + .get(`${url}?$includeErrors=false`) .expect('X-Error-Count', '0') .expect(200); expect(result.body).to.eql('DefaultValue'); @@ -79,22 +77,20 @@ describe('tweek api - propagate errors', () => { it('should skip error key on scan', async () => { const result = await client - .get( - `/api/v2/values/integration_tests/_?${identityType}=${identityId}&$propagateErrors=true`, - ) + .get(`/api/v2/values/integration_tests/_?${identityType}=${identityId}&$includeErrors=true`) .expect('X-Error-Count', '1') .expect(200); - expect(result.body).to.not.have.property('propagate_errors'); + expect(result.body).to.not.have.property('include_errors'); }); it('should return correct value if no error in scan', async () => { const result = await client - .get(`/api/v2/values/integration_tests/_?$propagateErrors=false`) + .get(`/api/v2/values/integration_tests/_?$includeErrors=false`) .expect('X-Error-Count', '0') .expect(200); - expect(result.body).to.deep.include({ propagate_errors: 'DefaultValue' }); + expect(result.body).to.deep.include({ include_errors: 'DefaultValue' }); }); }); }); diff --git a/services/api/Tweek.ApiService/Controllers/KeysController.cs b/services/api/Tweek.ApiService/Controllers/KeysController.cs index a1e9310ae..a6cf562b3 100644 --- a/services/api/Tweek.ApiService/Controllers/KeysController.cs +++ b/services/api/Tweek.ApiService/Controllers/KeysController.cs @@ -75,8 +75,8 @@ private static ConfigurationPath[] GetQuery(ConfigurationPath path, string[] inc [Produces("application/json")] [ProducesResponseType(typeof(object), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(void), (int)HttpStatusCode.Forbidden)] - public async Task GetAsyncSwagger([FromQuery] string keyPath, - [FromQuery( Name = "$flatten")] bool flatten = false, + public async Task GetAsyncSwagger([FromQuery] string keyPath, + [FromQuery( Name = "$flatten")] bool flatten = false, [FromQuery( Name = "$include")] List includeKeys = null) { if (System.String.IsNullOrWhiteSpace(keyPath)) return BadRequest("Missing key path"); @@ -93,7 +93,7 @@ public async Task GetAsync([FromRoute] string path) var allParams = PartitionByKey(HttpContext.Request.Query.ToDictionary(x => x.Key, x => x.Value), x => x.StartsWith("$")); var modifiers = allParams.Item1; var isFlatten = modifiers.TryGetValue("$flatten").Select(x => bool.Parse(x.First())).IfNone(false); - var propagateErrors = modifiers.TryGetValue("$propagateErrors").Select(x => bool.Parse(x.First())).IfNone(false); + var includeErrors = modifiers.TryGetValue("$includeErrors").Select(x => bool.Parse(x.First())).IfNone(false); var ignoreKeyTypes = modifiers.TryGetValue("$ignoreKeyTypes").Select(x => bool.Parse(x.First())).IfNone(false); var includePaths = modifiers.TryGetValue("$include").Select(x => x.ToArray()).IfNone(new string[] {}); @@ -125,9 +125,9 @@ public async Task GetAsync([FromRoute] string path) else if (values.Data.TryGetValue(root, out var value)) { result = ignoreKeyTypes ? TranslateValueToString(value) : value.Value; - } + } - if (!propagateErrors) + if (!includeErrors) { return Json(result); } diff --git a/services/git-service/BareRepository/tests-source/implementations/jpad/integration_tests/propagate_errors.jpad b/services/git-service/BareRepository/tests-source/implementations/jpad/integration_tests/include_errors.jpad similarity index 100% rename from services/git-service/BareRepository/tests-source/implementations/jpad/integration_tests/propagate_errors.jpad rename to services/git-service/BareRepository/tests-source/implementations/jpad/integration_tests/include_errors.jpad diff --git a/services/git-service/BareRepository/tests-source/manifests/integration_tests/propagate_errors.json b/services/git-service/BareRepository/tests-source/manifests/integration_tests/include_errors.json similarity index 68% rename from services/git-service/BareRepository/tests-source/manifests/integration_tests/propagate_errors.json rename to services/git-service/BareRepository/tests-source/manifests/integration_tests/include_errors.json index e2f36deba..3168ce762 100644 --- a/services/git-service/BareRepository/tests-source/manifests/integration_tests/propagate_errors.json +++ b/services/git-service/BareRepository/tests-source/manifests/integration_tests/include_errors.json @@ -1,7 +1,7 @@ { - "key_path": "integration_tests/propagate_errors", + "key_path": "integration_tests/include_errors", "meta": { - "name": "integration_tests/propagate_errors", + "name": "integration_tests/include_errors", "description": "", "tags": [], "readOnly": false,