Skip to content

Commit

Permalink
fix(http): return http when bootLogs is false
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Oct 15, 2023
1 parent c3c4476 commit d6fb999
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 68 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/core",
"version": "4.10.1",
"version": "4.10.2",
"description": "The plug and play Node.js framework.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down Expand Up @@ -57,8 +57,8 @@
"./commands/ServeCommand": "./src/commands/ServeCommand.js",
"./commands/TestCommand": "./src/commands/TestCommand.js",
"./commands/BuildCommand": "./src/commands/BuildCommand.js",
"./testing/BaseCliTest": "./src/testing/BaseCliTest.js",
"./testing/BaseRestTest": "./src/testing/BaseRestTest.js"
"./testing/BaseHttpTest": "./src/testing/BaseHttpTest.js",
"./testing/BaseConsoleTest": "./src/testing/BaseConsoleTest.js"
},
"imports": {
"#bin/*": "./bin/*.js",
Expand Down Expand Up @@ -106,8 +106,8 @@
"src/**/*.ts"
],
"exclude": [
"src/testing/BaseCliTest.ts",
"src/testing/BaseRestTest.ts",
"src/testing/BaseConsoleTest.ts",
"src/testing/BaseHttpTest.ts",
"src/repl/helpers/Command.ts",
"src/types/*"
],
Expand Down Expand Up @@ -204,8 +204,8 @@
"provider": "./templates/provider.edge",
"service": "./templates/service.edge",
"test": "./templates/test.edge",
"test-cli": "./templates/test-cli.edge",
"test-rest": "./templates/test-rest.edge",
"test-console": "./templates/test-console.edge",
"test-http": "./templates/test-http.edge",
"test-fn": "./templates/test-fn.edge",
"command": "node_modules/@athenna/artisan/templates/command.edge",
"controller": "node_modules/@athenna/http/templates/controller.edge",
Expand Down
4 changes: 2 additions & 2 deletions src/applications/Http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Http {
host: Config.get('http.host', '127.0.0.1'),
port: Config.get('http.port', 3000),
trace: Config.get('http.trace', false),
routePath: Path.routes(`rest.${Path.ext()}`),
routePath: Path.routes(`http.${Path.ext()}`),
kernelPath: '@athenna/http/kernels/HttpKernel'
})

Expand All @@ -37,7 +37,7 @@ export class Http {
await server.listen({ host: options.host, port: options.port })

if (Config.notExists('rc.bootLogs') || Config.is('rc.bootLogs', false)) {
return
return server
}

const host = server.getHost() || options.host
Expand Down
16 changes: 8 additions & 8 deletions src/commands/MakeTestCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ export class MakeTestCommand extends BaseCommand {
public isUnit: boolean

@Option({
description: 'Create a REST API test.',
signature: '-r, --rest',
description: 'Create a HTTP test.',
signature: '-h, --http',
default: false
})
public isRest: boolean
public isHttp: boolean

@Option({
description: 'Create a CLI test.',
signature: '-c, --cli',
description: 'Create a Console test.',
signature: '-c, --console',
default: false
})
public isCli: boolean
public isConsole: boolean

@Option({
description: 'Create the test as function instead of class.',
Expand All @@ -58,8 +58,8 @@ export class MakeTestCommand extends BaseCommand {

let template = 'test'

if (this.isCli) template = 'test-cli'
else if (this.isRest) template = 'test-rest'
if (this.isConsole) template = 'test-console'
else if (this.isHttp) template = 'test-http'
else if (this.isUnit) template = 'test' // This is necessary to avoid multiple options case.

if (this.isFunction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { BeforeAll } from '@athenna/test'
import { Ignite, type IgniteOptions } from '@athenna/core'
import { TestCommand } from '@athenna/artisan/testing/plugins'

export class BaseCliTest {
export class BaseConsoleTest {
public ignite: Ignite
public igniteOptions: IgniteOptions = {}
public artisanPath: string = Path.bootstrap(`artisan.${Path.ext()}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ServerImpl } from '@athenna/http'
import { AfterAll, BeforeAll } from '@athenna/test'
import { Ignite, type HttpOptions, type IgniteOptions } from '@athenna/core'

export class BaseRestTest {
export class BaseHttpTest {
public ignite: Ignite
public httpServer: ServerImpl
public httpOptions: HttpOptions = {}
Expand Down
12 changes: 0 additions & 12 deletions templates/test-cli.edge

This file was deleted.

12 changes: 12 additions & 0 deletions templates/test-console.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Test, type Context } from '@athenna/test'
import { BaseConsoleTest } from '@athenna/core/testing/BaseConsoleTest'

export default class {{ namePascal }} extends BaseConsoleTest {
@Test()
public async shouldBeAbleToExecuteConsoleCommands({ command }: Context) {
const output = await command.run('greet')

output.assertSucceeded()
output.assertLogged('Hello World!')
}
}
11 changes: 11 additions & 0 deletions templates/test-http.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Test, type Context } from '@athenna/test'
import { BaseHttpTest } from '@athenna/core/testing/BaseHttpTest'

export default class {{ namePascal }} extends BaseHttpTest {
@Test()
public async shouldBeAbleToExecuteHttpRequests({ request }: Context) {
const response = await request.get('/')

response.assertStatusCode(200)
}
}
11 changes: 0 additions & 11 deletions templates/test-rest.edge

This file was deleted.

1 change: 1 addition & 0 deletions tests/helpers/BaseCommandTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class BaseCommandTest {
await Folder.safeRemove(Path.app())
await Folder.safeRemove(Path.providers())
await Folder.safeRemove(Path.storage())
await Folder.safeRemove(Path.fixtures('storage'))
await Folder.safeRemove(Path.pwd('dist'))
await Folder.safeRemove(Path.pwd('build'))
await Folder.safeRemove(Path.pwd('build-relative'))
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/commands/MakeTestCommandTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default class MakeTestCommandTest extends BaseCommandTest {
}

@Test()
public async shouldBeAbleToCreateATestFileUsingRestTemplate({ assert, command }: Context) {
const output = await command.run('make:test TestTest --rest')
public async shouldBeAbleToCreateATestFileUsingHttpTemplate({ assert, command }: Context) {
const output = await command.run('make:test TestTest --http')

output.assertSucceeded()
output.assertLogged('[ MAKING TEST ]')
Expand All @@ -46,8 +46,8 @@ export default class MakeTestCommandTest extends BaseCommandTest {
}

@Test()
public async shouldBeAbleToCreateATestFileUsingCliTemplate({ assert, command }: Context) {
const output = await command.run('make:test TestTest --cli')
public async shouldBeAbleToCreateATestFileUsingConsoleTemplate({ assert, command }: Context) {
const output = await command.run('make:test TestTest --console')

output.assertSucceeded()
output.assertLogged('[ MAKING TEST ]')
Expand Down
10 changes: 0 additions & 10 deletions tests/unit/testing/BaseCliTestTest.ts

This file was deleted.

10 changes: 0 additions & 10 deletions tests/unit/testing/BaseRestTestTest.ts

This file was deleted.

0 comments on commit d6fb999

Please sign in to comment.