-
Notifications
You must be signed in to change notification settings - Fork 408
Remove SSRC async initializer #2478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove SSRC async initializer
- Loading branch information
commit 6a06c790a5fc2e1870b5d6a3189c6ac1f37f744a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ import { | |
| } from '../../../src/remote-config/remote-config-api-client-internal'; | ||
| import { deepCopy } from '../../../src/utils/deep-copy'; | ||
| import { | ||
| RemoteConfigServerCondition, RemoteConfigServerTemplate, RemoteConfigServerTemplateData | ||
| RemoteConfigServerCondition, RemoteConfigServerTemplateData | ||
| } from '../../../src/remote-config/remote-config-api'; | ||
|
|
||
| const expect = chai.expect; | ||
|
|
@@ -542,82 +542,6 @@ describe('RemoteConfig', () => { | |
| }); | ||
| }); | ||
|
|
||
| describe('getServerTemplate', () => { | ||
| const operationName = 'getServerTemplate'; | ||
|
|
||
| it('should propagate API errors', () => { | ||
| const stub = sinon | ||
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .rejects(INTERNAL_ERROR); | ||
| stubs.push(stub); | ||
|
|
||
| return remoteConfig.getServerTemplate().should.eventually.be.rejected.and.deep.equal(INTERNAL_ERROR); | ||
| }); | ||
|
|
||
| it('should resolve a server template on success', () => { | ||
| const stub = sinon | ||
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(SERVER_REMOTE_CONFIG_RESPONSE as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
|
|
||
| return remoteConfig.getServerTemplate() | ||
| .then((template) => { | ||
| expect(template.cache.conditions.length).to.equal(1); | ||
| expect(template.cache.conditions[0].name).to.equal('ios'); | ||
| expect(template.cache.conditions[0].expression).to.equal('device.os == \'ios\''); | ||
| expect(template.cache.etag).to.equal('etag-123456789012-5'); | ||
|
|
||
| const version = template.cache.version!; | ||
| expect(version.versionNumber).to.equal('86'); | ||
| expect(version.updateOrigin).to.equal('ADMIN_SDK_NODE'); | ||
| expect(version.updateType).to.equal('INCREMENTAL_UPDATE'); | ||
| expect(version.updateUser).to.deep.equal({ | ||
| email: '[email protected]' | ||
| }); | ||
| expect(version.description).to.equal('production version'); | ||
| expect(version.updateTime).to.equal('Mon, 15 Jun 2020 16:45:03 GMT'); | ||
|
|
||
| const key = 'holiday_promo_enabled'; | ||
| const p1 = template.cache.parameters[key]; | ||
| expect(p1.defaultValue).deep.equals({ value: 'true' }); | ||
| expect(p1.conditionalValues).deep.equals({ ios: { useInServerDefault: true } }); | ||
| expect(p1.description).equals('this is a promo'); | ||
| expect(p1.valueType).equals('BOOLEAN'); | ||
|
|
||
| const c = template.cache.conditions.find((c) => c.name === 'ios'); | ||
| expect(c).to.be.not.undefined; | ||
| const cond = c as RemoteConfigServerCondition; | ||
| expect(cond.name).to.equal('ios'); | ||
| expect(cond.expression).to.equal('device.os == \'ios\''); | ||
|
|
||
| const parsed = JSON.parse(JSON.stringify(template.cache)); | ||
| const expectedTemplate = deepCopy(SERVER_REMOTE_CONFIG_RESPONSE); | ||
| const expectedVersion = deepCopy(VERSION_INFO); | ||
| expectedVersion.updateTime = new Date(expectedVersion.updateTime).toUTCString(); | ||
| expectedTemplate.version = expectedVersion; | ||
| expect(parsed).deep.equals(expectedTemplate); | ||
| }); | ||
| }); | ||
|
|
||
| it('should set defaultConfig when passed', () => { | ||
| const defaultConfig = { | ||
| holiday_promo_enabled: false, | ||
| holiday_promo_discount: 20, | ||
| }; | ||
|
|
||
| const stub = sinon | ||
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(SERVER_REMOTE_CONFIG_RESPONSE as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
|
|
||
| return remoteConfig.getServerTemplate({ defaultConfig }) | ||
| .then((template) => { | ||
| expect(template.defaultConfig.holiday_promo_enabled).to.equal(false); | ||
| expect(template.defaultConfig.holiday_promo_discount).to.equal(20); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('initServerTemplate', () => { | ||
| it('should set and instantiates template when passed', () => { | ||
| const template = deepCopy(SERVER_REMOTE_CONFIG_RESPONSE) as RemoteConfigServerTemplateData; | ||
|
|
@@ -688,16 +612,17 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .rejects(INTERNAL_ERROR); | ||
| stubs.push(stub); | ||
|
|
||
| return remoteConfig.getServerTemplate().should.eventually.be.rejected.and.deep.equal(INTERNAL_ERROR); | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load().should.eventually.be.rejected.and.deep.equal(INTERNAL_ERROR); | ||
| }); | ||
|
|
||
| it('should reject when API response is invalid', () => { | ||
| const stub = sinon | ||
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(undefined); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate().should.eventually.be.rejected.and.have.property( | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load().should.eventually.be.rejected.and.have.property( | ||
| 'message', 'Invalid Remote Config template: undefined'); | ||
| }); | ||
|
|
||
|
|
@@ -708,7 +633,8 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(response as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate() | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .should.eventually.be.rejected.and.have.property( | ||
| 'message', `Invalid Remote Config template: ${JSON.stringify(response)}`); | ||
| }); | ||
|
|
@@ -720,7 +646,8 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(response as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate() | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .should.eventually.be.rejected.and.have.property( | ||
| 'message', 'Remote Config parameters must be a non-null object'); | ||
| }); | ||
|
|
@@ -732,7 +659,8 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(response as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate() | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .should.eventually.be.rejected.and.have.property( | ||
| 'message', 'Remote Config conditions must be an array'); | ||
| }); | ||
|
|
@@ -744,8 +672,9 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(response as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate() | ||
| .then((template) => { | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .then(() => { | ||
| // If parameters are not present in the response, we set it to an empty object. | ||
| expect(template.cache.parameters).deep.equals({}); | ||
| }); | ||
|
|
@@ -758,8 +687,9 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(response as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate() | ||
| .then((template) => { | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .then(() => { | ||
| // If conditions are not present in the response, we set it to an empty array. | ||
| expect(template.cache.conditions).deep.equals([]); | ||
| }); | ||
|
|
@@ -770,9 +700,9 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(SERVER_REMOTE_CONFIG_RESPONSE as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
|
|
||
| return remoteConfig.getServerTemplate() | ||
| .then((template) => { | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .then(() => { | ||
| expect(template.cache.conditions.length).to.equal(1); | ||
| expect(template.cache.conditions[0].name).to.equal('ios'); | ||
| expect(template.cache.conditions[0].expression).to.equal('device.os == \'ios\''); | ||
|
|
@@ -819,9 +749,9 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(response as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
|
|
||
| return remoteConfig.getServerTemplate() | ||
| .then((template) => { | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .then(() => { | ||
| expect(template.cache.etag).to.equal('etag-123456789012-5'); | ||
|
|
||
| const version = template.cache.version!; | ||
|
|
@@ -845,9 +775,9 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(response as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
|
|
||
| return remoteConfig.getServerTemplate() | ||
| .then((template) => { | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .then(() => { | ||
| expect(template.cache.etag).to.equal('etag-123456789012-5'); | ||
|
|
||
| const version = template.cache.version!; | ||
|
|
@@ -871,9 +801,9 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, operationName) | ||
| .resolves(response as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
|
|
||
| return remoteConfig.getServerTemplate() | ||
| .then((template) => { | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .then(() => { | ||
| expect(template.cache.etag).to.equal('etag-123456789012-5'); | ||
|
|
||
| const version = template.cache.version!; | ||
|
|
@@ -895,8 +825,9 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, 'getServerTemplate') | ||
| .resolves(SERVER_REMOTE_CONFIG_RESPONSE_2 as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate() | ||
| .then((template: RemoteConfigServerTemplate) => { | ||
| const template = remoteConfig.initServerTemplate(); | ||
| return template.load() | ||
| .then(() => { | ||
| const config = template.evaluate!(); | ||
| expect(config.dog_type).to.equal('corgi'); | ||
| expect(config.dog_type_enabled).to.equal(true); | ||
|
|
@@ -910,12 +841,13 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, 'getServerTemplate') | ||
| .resolves(SERVER_REMOTE_CONFIG_RESPONSE_2 as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate({ | ||
| const template = remoteConfig.initServerTemplate({ | ||
| defaultConfig: { | ||
| dog_coat: 'blue merle', | ||
| } | ||
| }) | ||
| .then((template: RemoteConfigServerTemplate) => { | ||
| }); | ||
| return template.load() | ||
| .then(() => { | ||
| const config = template.evaluate!(); | ||
| expect(config.dog_coat).to.equal(template.defaultConfig.dog_coat); | ||
| }); | ||
|
|
@@ -926,47 +858,47 @@ describe('RemoteConfig', () => { | |
| .stub(RemoteConfigApiClient.prototype, 'getServerTemplate') | ||
| .resolves(SERVER_REMOTE_CONFIG_RESPONSE_2 as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate({ | ||
| const template = remoteConfig.initServerTemplate({ | ||
| defaultConfig: { | ||
| dog_no_remote_default_value: 'local default' | ||
| } | ||
| }) | ||
| .then((template: RemoteConfigServerTemplate) => { | ||
| const config = template.evaluate!(); | ||
| expect(config.dog_no_remote_default_value).to.equal(template.defaultConfig.dog_no_remote_default_value); | ||
| }); | ||
| return template.load().then(() => { | ||
| const config = template.evaluate!(); | ||
| expect(config.dog_no_remote_default_value).to.equal(template.defaultConfig.dog_no_remote_default_value); | ||
| }); | ||
| }); | ||
|
|
||
| it('uses local default when in-app default value specified', () => { | ||
| const stub = sinon | ||
| .stub(RemoteConfigApiClient.prototype, 'getServerTemplate') | ||
| .resolves(SERVER_REMOTE_CONFIG_RESPONSE_2 as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate({ | ||
| const template = remoteConfig.initServerTemplate({ | ||
| defaultConfig: { | ||
| dog_use_inapp_default: '🐕' | ||
| } | ||
| }) | ||
| .then((template: RemoteConfigServerTemplate) => { | ||
| const config = template.evaluate!(); | ||
| expect(config.dog_use_inapp_default).to.equal(template.defaultConfig.dog_use_inapp_default); | ||
| }); | ||
| return template.load().then(() => { | ||
| const config = template.evaluate!(); | ||
| expect(config.dog_use_inapp_default).to.equal(template.defaultConfig.dog_use_inapp_default); | ||
| }); | ||
| }); | ||
|
|
||
| it('overrides local default when value exists', () => { | ||
| const stub = sinon | ||
| .stub(RemoteConfigApiClient.prototype, 'getServerTemplate') | ||
| .resolves(SERVER_REMOTE_CONFIG_RESPONSE_2 as RemoteConfigServerTemplateData); | ||
| stubs.push(stub); | ||
| return remoteConfig.getServerTemplate({ | ||
| const template = remoteConfig.initServerTemplate({ | ||
| defaultConfig: { | ||
| dog_type_enabled: false | ||
| } | ||
| }) | ||
| .then((template: RemoteConfigServerTemplate) => { | ||
| const config = template.evaluate!(); | ||
| expect(config.dog_type_enabled).to.equal(template.defaultConfig.dog_type_enabled); | ||
| }); | ||
| return template.load().then(() => { | ||
| const config = template.evaluate!(); | ||
| expect(config.dog_type_enabled).to.equal(template.defaultConfig.dog_type_enabled); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to update the internal API proposals to reflect this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking this is a subset of the approved API, ie I'm not adding an unreviewed method, so it wasn't worth a full amendment, but I'll add a note to the doc, comment-in the approvers and see if they have any objections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amendment approved!