Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HomelessDinosaur committed Jun 30, 2023
1 parent 3d57135 commit 878a5f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/resources/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
// limitations under the License.
import * as faas from '../faas/index';
import { HttpWorkerOptions, http } from '.';

jest.mock('portfinder', () => {
const originalModule = jest.requireActual('portfinder');

return {
__esmodule: true,
...originalModule,
getPort: (callback: (err, port) => void) => {
callback('', 1234);
},
};
});

jest.mock('../faas/index');

describe('HTTP Proxy', () => {
Expand All @@ -36,7 +49,7 @@ describe('HTTP Proxy', () => {

beforeAll(() => {
try {
http(mockApp, 1234);
http(mockApp);
} catch (err) {
error = err;
}
Expand All @@ -55,7 +68,7 @@ describe('HTTP Proxy', () => {
});

beforeAll(async () => {
http(mockApp, 1234, fakeCallback);
http(mockApp, fakeCallback);
});

it('should create a new FaasClient', () => {
Expand All @@ -81,7 +94,7 @@ describe('HTTP Proxy', () => {
});

beforeAll(async () => {
http(fakeFunc, 1234, fakeCallback);
http(fakeFunc, fakeCallback);
});

it('should create a new FaasClient', () => {
Expand Down
1 change: 1 addition & 0 deletions src/resources/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const http = (
'Unable to find open port. Try setting the env var `NITRIC_HTTP_PROXY_PORT`'
);
}

new HttpWorker(nodeApp, port, callback);
});

Expand Down

0 comments on commit 878a5f2

Please sign in to comment.