-
Notifications
You must be signed in to change notification settings - Fork 281
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
bug: Fix OrchestratorRecognizer null checks #3074
Conversation
rec.Initialize = sinon.fake(); | ||
|
||
let {dc, activity} = createTestDcAndActivity("hello"); | ||
rec.recognize(dc, activity) |
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.
Tests are a lot cleaner with async
syntax.
it('Expect initialize is called when orchestrator obj is null', async () => {
//if labelresolver is null, initialize() must be called
const result = [
{
score : 0.9,
label : {
name : "mockLabel"
}
}
];
const mockResolver = new MockResolver(result);
const testPaths = "test";
const rec = new OrchestratorAdaptiveRecognizer(testPaths, testPaths, mockResolver);
OrchestratorAdaptiveRecognizer.orchestrator = null;
rec.Initialize = sinon.fake();
const {dc, activity} = createTestDcAndActivity("hello");
const res = await rec.recognize(dc, activity);
assert(res);
...
});
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.
Thanks @joshgummersall, changed all usage of recognize
to async syntax.
|
||
let {dc, activity} = createTestDcAndActivity("hello"); | ||
rec.recognize(dc, activity) | ||
.catch(err => { |
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.
Same here - in fact, you can do:
await assert.rejects(() => rec.recognize(dc, activity);
to ensure that rec.recognize
fails.
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.
awesome, thanks @joshgummersall. Addressed.
Pull Request Test Coverage Report for Build 369070518
💛 - Coveralls |
Closes #3073
Description
Fix the Orchestrator null check on Initialize() to be consistent at lines 156 and 299
Specific Changes
Testing
Unit tests added to catch cases where either the
orchestrator
orlabelResolver
objects are not initialized beforescore
is called (would have failed this test before).