-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathlambroll_test.go
91 lines (86 loc) · 2.28 KB
/
lambroll_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package lambroll_test
import (
"testing"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/lambda/types"
"github.com/fujiwara/lambroll"
"github.com/google/go-cmp/cmp"
)
var testCasesFillDefaultValues = []struct {
name string
in *lambroll.Function
expect *lambroll.Function
}{
{
name: "normal",
in: &lambroll.Function{FunctionName: aws.String("test")},
expect: &lambroll.Function{
FunctionName: aws.String("test"),
Description: aws.String(""),
Architectures: []types.Architecture{types.ArchitectureX8664},
EphemeralStorage: &types.EphemeralStorage{
Size: aws.Int32(512),
},
Layers: []string{},
LoggingConfig: &types.LoggingConfig{
LogFormat: types.LogFormatText,
LogGroup: aws.String("/aws/lambda/test"),
},
MemorySize: aws.Int32(128),
SnapStart: &types.SnapStart{
ApplyOn: types.SnapStartApplyOnNone,
},
Timeout: aws.Int32(3),
TracingConfig: &types.TracingConfig{
Mode: types.TracingModePassThrough,
},
},
},
{
name: "logging config JSON",
in: &lambroll.Function{
FunctionName: aws.String("test"),
LoggingConfig: &types.LoggingConfig{
LogFormat: types.LogFormatJson,
},
},
expect: &lambroll.Function{
FunctionName: aws.String("test"),
Description: aws.String(""),
Architectures: []types.Architecture{types.ArchitectureX8664},
EphemeralStorage: &types.EphemeralStorage{
Size: aws.Int32(512),
},
Layers: []string{},
LoggingConfig: &types.LoggingConfig{
ApplicationLogLevel: "INFO",
LogFormat: types.LogFormatJson,
LogGroup: aws.String("/aws/lambda/test"),
SystemLogLevel: "INFO",
},
MemorySize: aws.Int32(128),
SnapStart: &types.SnapStart{
ApplyOn: types.SnapStartApplyOnNone,
},
Timeout: aws.Int32(3),
TracingConfig: &types.TracingConfig{
Mode: types.TracingModePassThrough,
},
},
},
}
func TestFillDefaultValues(t *testing.T) {
for _, tt := range testCasesFillDefaultValues {
t.Run(tt.name, func(t *testing.T) {
lambroll.FillDefaultValues(tt.in)
in := lambroll.ToJSONString(tt.in)
expect := lambroll.ToJSONString(tt.expect)
if diff := cmp.Diff(in, expect); diff != "" {
t.Errorf("differs: (-got +want)\n%s", diff)
}
})
}
}
func ptr[T any](v T) *T {
return &v
}