Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

Commit

Permalink
fix: fix load config case
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Feb 26, 2020
1 parent 421fab7 commit 59f9983
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
10 changes: 2 additions & 8 deletions packages/faas/test/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import { Configuration } from '@midwayjs/decorator';
import { join } from 'path';

@Configuration({
imports: [
join(__dirname, './fixtures/midway-plugin-mod')
],
importConfigs: [
join(__dirname, './config.default')
]
imports: [join(__dirname, './fixtures/midway-plugin-mod')],
})
export class ContainerLifeCycle {
}
export class ContainerLifeCycle {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import { Configuration } from '@midwayjs/decorator';

@Configuration({
imports: [],
importConfigs: ['./config.default'],
})
export class AutoConfiguraion {}
22 changes: 15 additions & 7 deletions packages/faas/test/fixtures/base-app-configuration/src/hello.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { inject, provide, func, config, FunctionHandler } from '../../../../src';
import {
inject,
provide,
func,
config,
FunctionHandler,
} from '../../../../src';
import { UserManager } from './lib/userManager';
import assert = require('assert');

@provide()
@func('index.handler')
export class HelloService implements FunctionHandler {

@inject()
ctx; // context
ctx; // context

@config()
@config('case')
allConfig;

@inject()
Expand All @@ -19,9 +24,12 @@ export class HelloService implements FunctionHandler {
articleManager: any;

async handler(event) {
console.log(this.allConfig);
assert.equal(await this.userManager.getUser(), 'harry', 'userManager.getUser should be ok');
assert.equal(
await this.userManager.getUser(),
'harry',
'userManager.getUser should be ok'
);

return event.text + (await this.articleManager.getOne());
return this.allConfig + event.text + (await this.articleManager.getOne());
}
}
9 changes: 6 additions & 3 deletions packages/faas/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ describe('test/index.test.ts', () => {
assert(data === 'abhello');
});

it.only('configuration test should be ok', async () => {
it('configuration test should be ok', async () => {
class TestFaaSStarter extends FaaSStarter {
prepareConfiguration() {
this.initConfiguration(join(__dirname, './configuration'), join(__dirname, 'fixtures/midway-plugin-mod'));
this.initConfiguration(
join(__dirname, './configuration'),
join(__dirname, 'fixtures/midway-plugin-mod')
);
}
}
const starter = new TestFaaSStarter({
Expand All @@ -145,6 +148,6 @@ describe('test/index.test.ts', () => {
{},
{ text: 'ab' }
);
assert(data === 'abone articlereplace manager');
assert(data === '1235abone articlereplace manager');
});
});

0 comments on commit 59f9983

Please sign in to comment.