Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
vangie committed Aug 29, 2019
1 parent 6827db3 commit a63d50f
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 114 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Expand Up @@ -2,3 +2,4 @@
*.min.js
node_modules/*
assets/scripts/lib/*
test/project/node_modules/*
32 changes: 16 additions & 16 deletions deploy/aliyunDeploy.test.js
Expand Up @@ -270,12 +270,12 @@ describe('AliyunDeploy', () => {
.then(() => aliyunDeploy.hooks['deploy:deploy']())
.then(() => {
const logs = [
'Creating log project sls-accountid-logs...',
'Created log project sls-accountid-logs',
'Creating log store sls-accountid-logs/my-service-dev...',
'Created log store sls-accountid-logs/my-service-dev',
'Creating log index for sls-accountid-logs/my-service-dev...',
'Created log index for sls-accountid-logs/my-service-dev',
'Creating log project sls-accountid-cn-shanghai-logs...',
'Created log project sls-accountid-cn-shanghai-logs',
'Creating log store sls-accountid-cn-shanghai-logs/my-service-dev...',
'Created log store sls-accountid-cn-shanghai-logs/my-service-dev',
'Creating log index for sls-accountid-cn-shanghai-logs/my-service-dev...',
'Created log index for sls-accountid-cn-shanghai-logs/my-service-dev',
'Creating RAM role sls-my-service-dev-exec-role...',
'Created RAM role sls-my-service-dev-exec-role',
'Creating RAM policy fc-my-service-dev-access...',
Expand All @@ -284,10 +284,10 @@ describe('AliyunDeploy', () => {
'Attached RAM policy fc-my-service-dev-access to sls-my-service-dev-exec-role',
'Creating service my-service-dev...',
'Created service my-service-dev',
'Creating bucket sls-accountid...',
'Created bucket sls-accountid',
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid',
'Creating bucket sls-accountid-cn-shanghai...',
'Created bucket sls-accountid-cn-shanghai',
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid-cn-shanghai...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid-cn-shanghai',
'Creating function my-service-dev-postTest...',
'Created function my-service-dev-postTest',
'Creating function my-service-dev-getTest...',
Expand Down Expand Up @@ -372,16 +372,16 @@ describe('AliyunDeploy', () => {
deployApiStub.returns(Promise.resolve());

const logs = [
'Log project sls-accountid-logs already exists.',
'Log store sls-accountid-logs/my-service-dev already exists.',
'Log store sls-accountid-logs/my-service-dev already has an index.',
'Log project sls-accountid-cn-shanghai-logs already exists.',
'Log store sls-accountid-cn-shanghai-logs/my-service-dev already exists.',
'Log store sls-accountid-cn-shanghai-logs/my-service-dev already has an index.',
'RAM role sls-my-service-dev-exec-role exists.',
'RAM policy fc-my-service-dev-access exists.',
'RAM policy fc-my-service-dev-access has been attached to sls-my-service-dev-exec-role.',
'Service my-service-dev already exists.',
'Bucket sls-accountid already exists.',
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid',
'Bucket sls-accountid-cn-shanghai already exists.',
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid-cn-shanghai...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid-cn-shanghai',
'Updating function my-service-dev-postTest...',
'Updated function my-service-dev-postTest',
'Updating function my-service-dev-getTest...',
Expand Down
32 changes: 16 additions & 16 deletions deploy/aliyunDeployFunction.test.js
Expand Up @@ -280,12 +280,12 @@ describe('AliyunDeployFunction', () => {
const logs = [
'Packaging function: postTest...',
'Compiling function "postTest"...',
'Creating log project sls-accountid-logs...',
'Created log project sls-accountid-logs',
'Creating log store sls-accountid-logs/my-service-dev...',
'Created log store sls-accountid-logs/my-service-dev',
'Creating log index for sls-accountid-logs/my-service-dev...',
'Created log index for sls-accountid-logs/my-service-dev',
'Creating log project sls-accountid-cn-shanghai-logs...',
'Created log project sls-accountid-cn-shanghai-logs',
'Creating log store sls-accountid-cn-shanghai-logs/my-service-dev...',
'Created log store sls-accountid-cn-shanghai-logs/my-service-dev',
'Creating log index for sls-accountid-cn-shanghai-logs/my-service-dev...',
'Created log index for sls-accountid-cn-shanghai-logs/my-service-dev',
'Creating RAM role sls-my-service-dev-exec-role...',
'Created RAM role sls-my-service-dev-exec-role',
'Creating RAM policy fc-my-service-dev-access...',
Expand All @@ -294,10 +294,10 @@ describe('AliyunDeployFunction', () => {
'Attached RAM policy fc-my-service-dev-access to sls-my-service-dev-exec-role',
'Creating service my-service-dev...',
'Created service my-service-dev',
'Creating bucket sls-accountid...',
'Created bucket sls-accountid',
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/postTest.zip to OSS bucket sls-accountid...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/postTest.zip to OSS bucket sls-accountid',
'Creating bucket sls-accountid-cn-shanghai...',
'Created bucket sls-accountid-cn-shanghai',
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/postTest.zip to OSS bucket sls-accountid-cn-shanghai...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/postTest.zip to OSS bucket sls-accountid-cn-shanghai',
'Creating function my-service-dev-postTest...',
'Created function my-service-dev-postTest',
'Creating RAM role sls-my-service-dev-invoke-role...',
Expand Down Expand Up @@ -371,16 +371,16 @@ describe('AliyunDeployFunction', () => {
const logs = [
'Packaging function: postTest...',
'Compiling function "postTest"...',
'Log project sls-accountid-logs already exists.',
'Log store sls-accountid-logs/my-service-dev already exists.',
'Log store sls-accountid-logs/my-service-dev already has an index.',
'Log project sls-accountid-cn-shanghai-logs already exists.',
'Log store sls-accountid-cn-shanghai-logs/my-service-dev already exists.',
'Log store sls-accountid-cn-shanghai-logs/my-service-dev already has an index.',
'RAM role sls-my-service-dev-exec-role exists.',
'RAM policy fc-my-service-dev-access exists.',
'RAM policy fc-my-service-dev-access has been attached to sls-my-service-dev-exec-role.',
'Service my-service-dev already exists.',
'Bucket sls-accountid already exists.',
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/postTest.zip to OSS bucket sls-accountid...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/postTest.zip to OSS bucket sls-accountid',
'Bucket sls-accountid-cn-shanghai already exists.',
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/postTest.zip to OSS bucket sls-accountid-cn-shanghai...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/postTest.zip to OSS bucket sls-accountid-cn-shanghai',
'Updating function my-service-dev-postTest...',
'Updated function my-service-dev-postTest',
'RAM role sls-my-service-dev-invoke-role exists.',
Expand Down
52 changes: 26 additions & 26 deletions deploy/lib/setupService.test.js
Expand Up @@ -145,30 +145,30 @@ describe('setupServices', () => {

return aliyunDeploy.setupService().then(() => {
expect(getLogProjectStub.calledOnce).toEqual(true);
expect(getLogProjectStub.calledWithExactly('sls-accountid-logs')).toEqual(true);
expect(getLogProjectStub.calledWithExactly('sls-accountid-cn-shanghai-logs')).toEqual(true);

expect(createLogProjectStub.calledAfter(getLogProjectStub)).toEqual(true);
expect(createLogProjectStub.calledOnce).toEqual(true);
expect(createLogProjectStub.getCall(0).args)
.toEqual(['sls-accountid-logs', logProject]);
.toEqual(['sls-accountid-cn-shanghai-logs', logProject]);

expect(getLogStoreStub.calledAfter(createLogProjectStub)).toEqual(true);
expect(getLogStoreStub.calledOnce).toEqual(true);
expect(getLogStoreStub.calledWithExactly('sls-accountid-logs', 'my-service-dev')).toEqual(true);
expect(getLogStoreStub.calledWithExactly('sls-accountid-cn-shanghai-logs', 'my-service-dev')).toEqual(true);

expect(createLogStoreStub.calledAfter(getLogStoreStub)).toEqual(true);
expect(createLogStoreStub.calledOnce).toEqual(true);
expect(createLogStoreStub.getCall(0).args)
.toEqual(['sls-accountid-logs', 'my-service-dev', logStore]);
.toEqual(['sls-accountid-cn-shanghai-logs', 'my-service-dev', logStore]);

expect(getLogIndexStub.calledAfter(createLogStoreStub)).toEqual(true);
expect(getLogIndexStub.calledOnce).toEqual(true);
expect(getLogIndexStub.calledWithExactly('sls-accountid-logs', 'my-service-dev')).toEqual(true);
expect(getLogIndexStub.calledWithExactly('sls-accountid-cn-shanghai-logs', 'my-service-dev')).toEqual(true);

expect(createLogIndexStub.calledAfter(getLogIndexStub)).toEqual(true);
expect(createLogIndexStub.calledOnce).toEqual(true);
expect(createLogIndexStub.getCall(0).args)
.toEqual(['sls-accountid-logs', 'my-service-dev', logIndex]);
.toEqual(['sls-accountid-cn-shanghai-logs', 'my-service-dev', logIndex]);

expect(setupRoleStub.calledAfter(createLogIndexStub)).toEqual(true);
expect(setupRoleStub.calledOnce).toEqual(true);
Expand All @@ -186,27 +186,27 @@ describe('setupServices', () => {

expect(getBucketStub.calledAfter(createServiceStub)).toEqual(true);
expect(getBucketStub.calledOnce).toEqual(true);
expect(getBucketStub.calledWithExactly('sls-accountid')).toEqual(true);
expect(getBucketStub.calledWithExactly('sls-accountid-cn-shanghai')).toEqual(true);

expect(createBucketStub.calledAfter(getBucketStub)).toEqual(true);
expect(createBucketStub.calledOnce).toEqual(true);
expect(createBucketStub.calledWithExactly('sls-accountid')).toEqual(true);
expect(createBucketStub.calledWithExactly('sls-accountid-cn-shanghai')).toEqual(true);

expect(resetOssClientStub.calledAfter(createBucketStub)).toEqual(true);
expect(resetOssClientStub.calledOnce).toEqual(true);
expect(resetOssClientStub.calledWithExactly('sls-accountid')).toEqual(true);
expect(resetOssClientStub.calledWithExactly('sls-accountid-cn-shanghai')).toEqual(true);

const logs = [
'Creating log project sls-accountid-logs...',
'Created log project sls-accountid-logs',
'Creating log store sls-accountid-logs/my-service-dev...',
'Created log store sls-accountid-logs/my-service-dev',
'Creating log index for sls-accountid-logs/my-service-dev...',
'Created log index for sls-accountid-logs/my-service-dev',
'Creating log project sls-accountid-cn-shanghai-logs...',
'Created log project sls-accountid-cn-shanghai-logs',
'Creating log store sls-accountid-cn-shanghai-logs/my-service-dev...',
'Created log store sls-accountid-cn-shanghai-logs/my-service-dev',
'Creating log index for sls-accountid-cn-shanghai-logs/my-service-dev...',
'Created log index for sls-accountid-cn-shanghai-logs/my-service-dev',
'Creating service my-service-dev...',
'Created service my-service-dev',
'Creating bucket sls-accountid...',
'Created bucket sls-accountid'
'Creating bucket sls-accountid-cn-shanghai...',
'Created bucket sls-accountid-cn-shanghai'
];
expect(consoleLogStub.callCount).toEqual(logs.length);
for (var i = 0; i < consoleLogStub.callCount; ++i) {
Expand Down Expand Up @@ -234,19 +234,19 @@ describe('setupServices', () => {

return aliyunDeploy.setupService().then(() => {
expect(getLogProjectStub.calledOnce).toEqual(true);
expect(getLogProjectStub.calledWithExactly('sls-accountid-logs')).toEqual(true);
expect(getLogProjectStub.calledWithExactly('sls-accountid-cn-shanghai-logs')).toEqual(true);

expect(createLogProjectStub.called).toEqual(false);

expect(getLogStoreStub.calledAfter(getLogProjectStub)).toEqual(true);
expect(getLogStoreStub.calledOnce).toEqual(true);
expect(getLogStoreStub.calledWithExactly('sls-accountid-logs', 'my-service-dev')).toEqual(true);
expect(getLogStoreStub.calledWithExactly('sls-accountid-cn-shanghai-logs', 'my-service-dev')).toEqual(true);

expect(createLogStoreStub.called).toEqual(false);

expect(getLogIndexStub.calledAfter(getLogStoreStub)).toEqual(true);
expect(getLogIndexStub.calledOnce).toEqual(true);
expect(getLogIndexStub.calledWithExactly('sls-accountid-logs', 'my-service-dev')).toEqual(true);
expect(getLogIndexStub.calledWithExactly('sls-accountid-cn-shanghai-logs', 'my-service-dev')).toEqual(true);

expect(createLogIndexStub.called).toEqual(false);

Expand All @@ -261,20 +261,20 @@ describe('setupServices', () => {

expect(getBucketStub.calledAfter(getServiceStub)).toEqual(true);
expect(getBucketStub.calledOnce).toEqual(true);
expect(getBucketStub.calledWithExactly('sls-accountid')).toEqual(true);
expect(getBucketStub.calledWithExactly('sls-accountid-cn-shanghai')).toEqual(true);

expect(createBucketStub.calledOnce).toEqual(false);

expect(resetOssClientStub.calledAfter(getBucketStub)).toEqual(true);
expect(resetOssClientStub.calledOnce).toEqual(true);
expect(resetOssClientStub.calledWithExactly('sls-accountid')).toEqual(true);
expect(resetOssClientStub.calledWithExactly('sls-accountid-cn-shanghai')).toEqual(true);

const logs = [
'Log project sls-accountid-logs already exists.',
'Log store sls-accountid-logs/my-service-dev already exists.',
'Log store sls-accountid-logs/my-service-dev already has an index.',
'Log project sls-accountid-cn-shanghai-logs already exists.',
'Log store sls-accountid-cn-shanghai-logs/my-service-dev already exists.',
'Log store sls-accountid-cn-shanghai-logs/my-service-dev already has an index.',
'Service my-service-dev already exists.',
'Bucket sls-accountid already exists.'
'Bucket sls-accountid-cn-shanghai already exists.'
];
expect(consoleLogStub.callCount).toEqual(logs.length);
for (var i = 0; i < consoleLogStub.callCount; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions deploy/lib/uploadArtifacts.test.js
Expand Up @@ -65,8 +65,8 @@ describe('UploadArtifacts', () => {
'/projects/.serverless/my-service.zip'
)).toEqual(true);
const logs = [
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid'
'Uploading serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid-cn-shanghai...',
'Uploaded serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip to OSS bucket sls-accountid-cn-shanghai'
];
expect(consoleLogStub.callCount).toEqual(logs.length);
for (var i = 0; i < consoleLogStub.callCount; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions logs/lib/retrieveLogs.test.js
Expand Up @@ -70,7 +70,7 @@ describe('DisplayServiceLogs', () => {
expect(consoleLogStub.getCall(0).args[0].split('\n')).toEqual(expectedOutput);
expect(getLogsIfAvailableStub.calledOnce).toEqual(true);
expect(getLogsIfAvailableStub.getCall(0).args).toEqual([
'sls-accountid-logs',
'sls-accountid-cn-shanghai-logs',
'my-service-dev',
1,
{ functionName: 'my-service-dev-postTest' },
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('DisplayServiceLogs', () => {
await aliyunLogs.retrieveLogs();
expect(consoleLogStub.getCall(0).args[0].split('\n')).toEqual(expectedOutput);
expect(getLogsIfAvailableStub.getCall(0).args).toEqual([
'sls-accountid-logs',
'sls-accountid-cn-shanghai-logs',
'my-service-dev',
1,
{ functionName: 'my-service-dev-postTest' },
Expand Down
8 changes: 4 additions & 4 deletions package/lib/compileFunctions.test.js
Expand Up @@ -77,7 +77,7 @@ describe('CompileFunctions', () => {
'timeout': 30,
'runtime': 'nodejs6',
'code': {
'ossBucketName': 'sls-accountid',
'ossBucketName': 'sls-accountid-cn-shanghai',
'ossObjectName': 'serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip'
}
}
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('CompileFunctions', () => {
'timeout': 30,
'runtime': 'nodejs6',
'code': {
'ossBucketName': 'sls-accountid',
'ossBucketName': 'sls-accountid-cn-shanghai',
'ossObjectName': 'serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip'
}
}
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('CompileFunctions', () => {
'timeout': 120,
'runtime': 'nodejs6',
'code': {
'ossBucketName': 'sls-accountid',
'ossBucketName': 'sls-accountid-cn-shanghai',
'ossObjectName': 'serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip'
}
}
Expand Down Expand Up @@ -194,7 +194,7 @@ describe('CompileFunctions', () => {
'timeout': 120,
'runtime': 'nodejs6',
'code': {
'ossBucketName': 'sls-accountid',
'ossBucketName': 'sls-accountid-cn-shanghai',
'ossObjectName': 'serverless/my-service/dev/1500622721413-2017-07-21T07:38:41.413Z/my-service.zip'
}
}
Expand Down

0 comments on commit a63d50f

Please sign in to comment.