-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
spec_test.go
72 lines (68 loc) · 2 KB
/
spec_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package appspec_test
import (
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/google/go-cmp/cmp"
"github.com/kayac/ecspresso/appspec"
"github.com/kayac/go-config"
)
var expected = &appspec.AppSpec{
Version: aws.String("0.0"),
Resources: []*appspec.Resource{
{
TargetService: &appspec.TargetService{
Type: aws.String("AWS::ECS::Service"),
Properties: &appspec.Properties{
TaskDefinition: aws.String("arn:aws:ecs:us-east-1:111222333444:task-definition/my-task-definition-family-name:1"),
LoadBalancerInfo: &appspec.LoadBalancerInfo{
ContainerName: aws.String("SampleApplicationName"),
ContainerPort: aws.Int64(80),
},
PlatformVersion: aws.String("LATEST"),
NetworkConfiguration: &appspec.NetworkConfiguration{
AwsvpcConfiguration: &appspec.AwsVpcConfiguration{
Subnets: []*string{
aws.String("subnet-1234abcd"),
aws.String("subnet-5678abcd"),
},
SecurityGroups: []*string{
aws.String("sg-12345678"),
},
AssignPublicIp: aws.String("ENABLED"),
},
},
CapacityProviderStrategy: []*appspec.CapacityProviderStrategy{
{
CapacityProvider: aws.String("FARGATE_SPOT"),
Base: aws.Int64(1),
Weight: aws.Int64(2),
},
{
CapacityProvider: aws.String("FARGATE"),
Base: aws.Int64(0),
Weight: aws.Int64(1),
},
},
},
},
},
},
Hooks: []*appspec.Hook{
{BeforeInstall: "LambdaFunctionToValidateBeforeInstall"},
{AfterInstall: "LambdaFunctionToValidateAfterTraffic"},
{AfterAllowTestTraffic: "LambdaFunctionToValidateAfterTestTrafficStarts"},
{BeforeAllowTraffic: "LambdaFunctionToValidateBeforeAllowingProductionTraffic"},
{AfterAllowTraffic: "LambdaFunctionToValidateAfterAllowingProductionTraffic"},
},
}
func TestAppSpec(t *testing.T) {
var s appspec.AppSpec
err := config.LoadWithEnv(&s, "test.yml")
if err != nil {
t.Error(err)
}
t.Log(s.String())
if diff := cmp.Diff(&s, expected); diff != "" {
t.Error(diff)
}
}