-
Notifications
You must be signed in to change notification settings - Fork 137
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
Unit Test Case for useInferenceServices #2340
Unit Test Case for useInferenceServices #2340
Conversation
k8sListResourceMock.mockReturnValue(Promise.reject('error')); | ||
const renderResult = testHook(useInferenceServices)('namespace'); | ||
expect(k8sListResourceMock).toHaveBeenCalledTimes(1); | ||
expect(renderResult).hookToStrictEqual(standardUseFetchState([], false)); | ||
expect(renderResult).hookToHaveUpdateCount(1); | ||
|
||
// // Wait for the hook to handle the error | ||
await renderResult.waitForNextUpdate(); | ||
expect(renderResult).hookToStrictEqual( | ||
standardUseFetchState([], false, new Error('No Inference Services found.')), |
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.
Reject with an instance of Error
and assert that error is returned.
k8sListResourceMock.mockReturnValue(Promise.reject('error')); | |
const renderResult = testHook(useInferenceServices)('namespace'); | |
expect(k8sListResourceMock).toHaveBeenCalledTimes(1); | |
expect(renderResult).hookToStrictEqual(standardUseFetchState([], false)); | |
expect(renderResult).hookToHaveUpdateCount(1); | |
// // Wait for the hook to handle the error | |
await renderResult.waitForNextUpdate(); | |
expect(renderResult).hookToStrictEqual( | |
standardUseFetchState([], false, new Error('No Inference Services found.')), | |
k8sListResourceMock.mockReturnValue(Promise.reject(new Error('error'))); | |
const renderResult = testHook(useInferenceServices)('namespace'); | |
expect(k8sListResourceMock).toHaveBeenCalledTimes(1); | |
expect(renderResult).hookToStrictEqual(standardUseFetchState([], false)); | |
expect(renderResult).hookToHaveUpdateCount(1); | |
// // Wait for the hook to handle the error | |
await renderResult.waitForNextUpdate(); | |
expect(renderResult).hookToStrictEqual( | |
standardUseFetchState([], false, new Error('error')), |
return getInferenceServiceContext(namespace, LABEL_SELECTOR_DASHBOARD_RESOURCE); | ||
return getInferenceServiceContext(namespace, LABEL_SELECTOR_DASHBOARD_RESOURCE).catch(() => { | ||
throw new Error('No Inference Services found.'); | ||
}); |
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.
Remove this change along with the change to the test that mocks the error thrown.
727996d
to
c95ac2e
Compare
@uidoyen please add another test for the missing code coverage. You can assert that |
589b3a8
to
4232433
Compare
@christianvogt Updated the test case based on your comment as well as the latest hook update. |
4232433
to
ed5d99d
Compare
@uidoyen you don't have a test case for when |
ed5d99d
to
6925570
Compare
6925570
to
245b339
Compare
@christianvogt added test case when |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Closes: RHOAIENG-1852
Description
Unit test case for: frontend/src/pages/modelServing/useInferenceServices.ts
How Has This Been Tested?
npm run test
Test Impact
Request review criteria:
Self checklist (all need to be checked):
If you have UI changes:
After the PR is posted & before it merges:
main