Skip to content

Commit 90a0bfb

Browse files
committed
feat(testlab): set port to 0 in givenHttpServerConfig
Modify the test helper `givenHttpServerConfig` to explicitly set the port to zero. With this change in place, applications can use this helper in acceptation tests without having to explicitly specify `{port: 0}` to override RestServer's default port 3000.
1 parent 3907df4 commit 90a0bfb

File tree

11 files changed

+23
-29
lines changed

11 files changed

+23
-29
lines changed

examples/hello-world/test/acceptance/application.acceptance.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ describe('Application', () => {
3131

3232
function givenAnApplication() {
3333
app = new HelloWorldApplication({
34-
rest: givenHttpServerConfig({
35-
port: 0,
36-
}),
34+
rest: givenHttpServerConfig(),
3735
disableConsoleLog: true,
3836
});
3937
}

examples/todo-list/test/acceptance/todo-list-todo.acceptance.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ describe('TodoListApplication', () => {
124124

125125
async function givenRunningApplicationWithCustomConfiguration() {
126126
app = new TodoListApplication({
127-
rest: givenHttpServerConfig({
128-
port: 0,
129-
}),
127+
rest: givenHttpServerConfig(),
130128
});
131129

132130
await app.boot();

examples/todo-list/test/acceptance/todo-list.acceptance.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ describe('TodoListApplication', () => {
145145

146146
async function givenRunningApplicationWithCustomConfiguration() {
147147
app = new TodoListApplication({
148-
rest: givenHttpServerConfig({
149-
port: 0,
150-
}),
148+
rest: givenHttpServerConfig(),
151149
});
152150

153151
await app.boot();

examples/todo-list/test/acceptance/todo.acceptance.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ describe('TodoListApplication', () => {
143143

144144
async function givenRunningApplicationWithCustomConfiguration() {
145145
app = new TodoListApplication({
146-
rest: givenHttpServerConfig({
147-
port: 0,
148-
}),
146+
rest: givenHttpServerConfig(),
149147
});
150148

151149
await app.boot();

examples/todo/test/acceptance/todo.acceptance.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ describe('TodoApplication', () => {
175175

176176
async function givenRunningApplicationWithCustomConfiguration() {
177177
app = new TodoListApplication({
178-
rest: givenHttpServerConfig({
179-
port: 0,
180-
}),
178+
rest: givenHttpServerConfig(),
181179
});
182180

183181
await app.boot();

packages/boot/test/acceptance/controller.booter.acceptance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('controller booter acceptance tests', () => {
4141

4242
const MyApp = require(resolve(SANDBOX_PATH, 'application.js')).BooterApp;
4343
app = new MyApp({
44-
rest: givenHttpServerConfig({port: 0}),
44+
rest: givenHttpServerConfig(),
4545
});
4646
}
4747

packages/cli/generators/app/templates/test/acceptance/ping.controller.acceptance.ts.ejs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ describe('PingController', () => {
3030

3131
function givenAnApplication() {
3232
app = new <%= project.applicationName %>({
33-
rest: givenHttpServerConfig({
34-
port: 0,
35-
}),
33+
rest: givenHttpServerConfig(),
3634
});
3735
}
3836
});

packages/http-server/test/integration/http-server.integration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ describe('HttpServer (integration)', () => {
158158
});
159159

160160
it('supports HTTPS protocol with a pfx file', async () => {
161-
const options = {usePfx: true};
162-
const serverOptions = givenHttpServerConfig();
163-
Object.assign(serverOptions, options);
161+
const serverOptions = givenHttpServerConfig({
162+
usePfx: true,
163+
});
164164
const httpsServer: HttpServer = givenHttpsServer(serverOptions);
165165
await httpsServer.start();
166166
const response = await httpsGetAsync(httpsServer.url);

packages/rest/test/acceptance/coercion/coercion.acceptance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('Coercion', () => {
9696
});
9797

9898
async function givenAClient() {
99-
app = new RestApplication({rest: givenHttpServerConfig({port: 0})});
99+
app = new RestApplication({rest: givenHttpServerConfig()});
100100
app.controller(MyController);
101101
await app.start();
102102
client = createRestAppClient(app);

packages/rest/test/acceptance/validation/validation.acceptance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ describe('Validation at REST level', () => {
156156
}
157157

158158
async function givenAnAppAndAClient(controller: ControllerClass) {
159-
app = new RestApplication({rest: givenHttpServerConfig({port: 0})});
159+
app = new RestApplication({rest: givenHttpServerConfig()});
160160
app.controller(controller);
161161
await app.start();
162162

0 commit comments

Comments
 (0)