mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Split test into granular cases.
This commit is contained in:
parent
7383281a6b
commit
dd8b60675c
@ -95,32 +95,97 @@ describe('#compileStage()', () => {
|
||||
});
|
||||
|
||||
describe('tags', () => {
|
||||
it('should add tag from provider.stackTags and provider.tags', () => {
|
||||
it('should create a dedicated stage resource if provider.stackTags is configured', () => {
|
||||
provider.stackTags = {
|
||||
foo: 'bar',
|
||||
};
|
||||
provider.tags = {
|
||||
// override stackTags
|
||||
foo: 'high-priority',
|
||||
foo: '1',
|
||||
};
|
||||
|
||||
awsCompileApigEvents.compileStage().then(() => {
|
||||
const template = awsCompileApigEvents.serverless.service.provider
|
||||
.compiledCloudFormationTemplate;
|
||||
const actual = template.Resources[stageLogicalId];
|
||||
expect(actual).to.deep.equal({
|
||||
const resources = awsCompileApigEvents.serverless.service.provider
|
||||
.compiledCloudFormationTemplate.Resources;
|
||||
expect(resources[awsCompileApigEvents.apiGatewayDeploymentLogicalId]).to.deep.equal({
|
||||
Properties: {},
|
||||
});
|
||||
|
||||
expect(resources[stageLogicalId]).to.deep.equal({
|
||||
Type: 'AWS::ApiGateway::Stage',
|
||||
Properties: {
|
||||
DeploymentId: {
|
||||
Ref: awsCompileApigEvents.apiGatewayDeploymentLogicalId,
|
||||
},
|
||||
RestApiId: {
|
||||
Ref: awsCompileApigEvents.apiGatewayRestApiLogicalId,
|
||||
},
|
||||
DeploymentId: {
|
||||
Ref: awsCompileApigEvents.apiGatewayDeploymentLogicalId,
|
||||
},
|
||||
StageName: stage,
|
||||
TracingEnabled: false,
|
||||
Tags: [
|
||||
{ Key: 'foo', Value: 'high-priority' },
|
||||
{ Key: 'foo', Value: '1' },
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should create a dedicated stage resource if provider.tags is configured', () => {
|
||||
provider.tags = {
|
||||
foo: '1',
|
||||
};
|
||||
|
||||
awsCompileApigEvents.compileStage().then(() => {
|
||||
const resources = awsCompileApigEvents.serverless.service.provider
|
||||
.compiledCloudFormationTemplate.Resources;
|
||||
expect(resources[awsCompileApigEvents.apiGatewayDeploymentLogicalId]).to.deep.equal({
|
||||
Properties: {},
|
||||
});
|
||||
|
||||
expect(resources[stageLogicalId]).to.deep.equal({
|
||||
Type: 'AWS::ApiGateway::Stage',
|
||||
Properties: {
|
||||
RestApiId: {
|
||||
Ref: awsCompileApigEvents.apiGatewayRestApiLogicalId,
|
||||
},
|
||||
DeploymentId: {
|
||||
Ref: awsCompileApigEvents.apiGatewayDeploymentLogicalId,
|
||||
},
|
||||
StageName: stage,
|
||||
TracingEnabled: false,
|
||||
Tags: [
|
||||
{ Key: 'foo', Value: '1' },
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should override provider.stackTags by provider.tags', () => {
|
||||
provider.stackTags = {
|
||||
foo: 'from-stackTags',
|
||||
bar: 'from-stackTags',
|
||||
};
|
||||
provider.tags = {
|
||||
foo: 'from-tags',
|
||||
buz: 'from-tags',
|
||||
};
|
||||
|
||||
awsCompileApigEvents.compileStage().then(() => {
|
||||
const resources = awsCompileApigEvents.serverless.service.provider
|
||||
.compiledCloudFormationTemplate.Resources;
|
||||
|
||||
expect(resources[stageLogicalId]).to.deep.equal({
|
||||
Type: 'AWS::ApiGateway::Stage',
|
||||
Properties: {
|
||||
RestApiId: {
|
||||
Ref: awsCompileApigEvents.apiGatewayRestApiLogicalId,
|
||||
},
|
||||
DeploymentId: {
|
||||
Ref: awsCompileApigEvents.apiGatewayDeploymentLogicalId,
|
||||
},
|
||||
StageName: stage,
|
||||
TracingEnabled: false,
|
||||
Tags: [
|
||||
{ Key: 'foo', Value: 'from-tags' },
|
||||
{ Key: 'bar', Value: 'from-stackTags' },
|
||||
{ Key: 'buz', Value: 'from-tags' },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user