-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
129 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ test/__app | |
build | ||
dist | ||
shrinkwrap.yaml | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { assert } from '@japa/assert' | ||
import { configure, processCLIArgs, run } from '@japa/runner' | ||
import { fileSystem } from '@japa/file-system' | ||
|
||
processCLIArgs(process.argv.splice(2)) | ||
|
||
configure({ | ||
files: ['tests/**/*.spec.ts'], | ||
plugins: [assert()], | ||
plugins: [assert(), fileSystem()], | ||
}) | ||
|
||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,4 @@ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Package entrypoint | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Export values from the package entrypoint as you see fit. | ||
| | ||
*/ | ||
|
||
export { GeoLite2 } from './src/geolite2.js' | ||
export { configure } from './configure.js' | ||
export { stubsRoot } from './stubs/main.js' | ||
export { defineConfig } from './src/define_config.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { test } from '@japa/runner' | ||
import { fileURLToPath } from 'node:url' | ||
import { IgnitorFactory } from '@adonisjs/core/factories' | ||
import Configure from '@adonisjs/core/commands/configure' | ||
|
||
const BASE_URL = new URL('./tmp/', import.meta.url) | ||
|
||
test.group('Configure', (group) => { | ||
group.each.setup(({ context }) => { | ||
context.fs.baseUrl = BASE_URL | ||
context.fs.basePath = fileURLToPath(BASE_URL) | ||
}) | ||
|
||
test('create config file, register provider and update meta files', async ({ fs, assert }) => { | ||
const ignitor = new IgnitorFactory() | ||
.withCoreProviders() | ||
.withCoreConfig() | ||
.create(BASE_URL, { | ||
importer: (filePath) => { | ||
if (filePath.startsWith('./') || filePath.startsWith('../')) { | ||
return import(new URL(filePath, BASE_URL).href) | ||
} | ||
|
||
return import(filePath) | ||
}, | ||
}) | ||
|
||
await fs.create('.env', '') | ||
await fs.createJson('tsconfig.json', {}) | ||
await fs.create('start/kernel.ts', `router.use([])`) | ||
await fs.create('adonisrc.ts', `export default defineConfig({}) {}`) | ||
|
||
const app = ignitor.createApp('web') | ||
await app.init() | ||
await app.boot() | ||
|
||
const ace = await app.container.make('ace') | ||
const command = await ace.create(Configure, ['../../index.js']) | ||
await command.exec() | ||
|
||
await assert.fileExists('config/geolite2.ts') | ||
}).timeout(60 * 1000) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { test } from '@japa/runner' | ||
import { IgnitorFactory } from '@adonisjs/core/factories' | ||
import { defineConfig } from '../src/define_config.js' | ||
import GeoLite2Manager from '../src/manager.js' | ||
|
||
const BASE_URL = new URL('./tmp/', import.meta.url) | ||
|
||
test.group('GeoLite2 Provider', () => { | ||
test('register geolite2 provider', async ({ assert }) => { | ||
const ignitor = new IgnitorFactory() | ||
.withCoreConfig() | ||
.withCoreProviders() | ||
.merge({ | ||
config: { | ||
geolite2: defineConfig({ | ||
downloadDirectory: './tmp', | ||
cache: 6000, | ||
}), | ||
}, | ||
rcFileContents: { | ||
providers: [() => import('../providers/geolite2_provider.js')], | ||
}, | ||
}) | ||
.create(BASE_URL) | ||
|
||
const app = ignitor.createApp('web') | ||
await app.init() | ||
await app.boot() | ||
assert.instanceOf(await app.container.make('geolite2'), GeoLite2Manager) | ||
await app.terminate() | ||
}) | ||
|
||
test('throw error when config is invalid', async () => { | ||
const ignitor = new IgnitorFactory() | ||
.withCoreConfig() | ||
.withCoreProviders() | ||
.merge({ | ||
config: { | ||
geolite2: {}, | ||
}, | ||
rcFileContents: { | ||
providers: [() => import('../providers/geolite2_provider.js')], | ||
}, | ||
}) | ||
.create(BASE_URL) | ||
|
||
const app = ignitor.createApp('web') | ||
await app.init() | ||
await app.boot() | ||
await app.container.make('geolite2') | ||
}).throws( | ||
'Invalid default export from "config/geolite2.ts" file. Make sure to use defineConfig method' | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters