Skip to content

Commit

Permalink
Merge pull request #224 from AthennaIO/develop
Browse files Browse the repository at this point in the history
refactor(test): dont change environment after running
  • Loading branch information
jlenon7 authored Apr 27, 2024
2 parents 427d395 + 80c1fc9 commit 96485a4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 30 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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/core",
"version": "4.36.0",
"version": "4.37.0",
"description": "One foundation for multiple applications.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down
21 changes: 2 additions & 19 deletions src/testing/BaseConsoleTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
* file that was distributed with this source code.
*/

import { AfterAll, BeforeAll } from '@athenna/test'
import { Path, Json, Options } from '@athenna/common'
import { BeforeAll } from '@athenna/test'
import { Path, Options } from '@athenna/common'
import { Ignite, type IgniteOptions } from '@athenna/core'
import { TestCommand } from '@athenna/artisan/testing/plugins'

export class BaseConsoleTest {
private env = Json.copy(process.env)
private config = Json.copy(Config.get())
public ignite: Ignite
public igniteOptions: IgniteOptions = {}
public artisanPath: string = Path.bootstrap(`artisan.${Path.ext()}`)
Expand All @@ -27,21 +25,6 @@ export class BaseConsoleTest {
Path.toHref(Path.bootstrap(`test.${Path.ext()}`)),
this.getIgniteOptions()
)

const { ViewProvider } = await import('@athenna/view')
const { ArtisanProvider } = await import('@athenna/artisan')

new ViewProvider().register()
new ArtisanProvider().register()
}

@AfterAll()
public async baseAfterAll() {
ioc.reconstruct()
process.env = Json.copy(this.env)
Object.keys(this.config).forEach(key =>
Config.set(key, Json.copy(this.config[key]))
)
}

private getIgniteOptions() {
Expand Down
9 changes: 1 addition & 8 deletions src/testing/BaseHttpTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
*/

import { ServerImpl } from '@athenna/http'
import { Path, Options } from '@athenna/common'
import { AfterAll, BeforeAll } from '@athenna/test'
import { Path, Json, Options } from '@athenna/common'
import { Ignite, type HttpOptions, type IgniteOptions } from '@athenna/core'

export class BaseHttpTest {
private env = Json.copy(process.env)
private config = Json.copy(Config.get())
public ignite: Ignite
public httpServer: ServerImpl
public httpOptions: HttpOptions = {}
Expand All @@ -33,11 +31,6 @@ export class BaseHttpTest {
@AfterAll()
public async baseAfterAll() {
await this.httpServer.close()
ioc.reconstruct()
process.env = Json.copy(this.env)
Object.keys(this.config).forEach(key =>
Config.set(key, Json.copy(this.config[key]))
)
}

private getHttpOptions() {
Expand Down

0 comments on commit 96485a4

Please sign in to comment.