@@ -41,6 +41,7 @@ func TestInitEnvOpts_Validate(t *testing.T) {
41
41
inDefault bool
42
42
inVPCID string
43
43
inPublicIDs []string
44
+ inPrivateIDs []string
44
45
inVPCCIDR net.IPNet
45
46
inPublicCIDRs []string
46
47
@@ -61,11 +62,11 @@ func TestInitEnvOpts_Validate(t *testing.T) {
61
62
62
63
wantedErrMsg : fmt .Sprintf ("environment name 123env is invalid: %s" , errValueBadFormat ),
63
64
},
64
- "cannot specify both vpc resources importing flags and configuing flags" : {
65
+ "cannot specify both vpc resources importing flags and configuring flags" : {
65
66
inEnvName : "test-pdx" ,
66
67
inAppName : "phonetool" ,
67
68
inPublicCIDRs : []string {"mockCIDR" },
68
- inPublicIDs : []string {"mockID" },
69
+ inPublicIDs : []string {"mockID" , "anotherMockID" },
69
70
inVPCCIDR : net.IPNet {
70
71
IP : net.IP {10 , 1 , 232 , 0 },
71
72
Mask : net.IPMask {255 , 255 , 255 , 0 },
@@ -106,6 +107,29 @@ func TestInitEnvOpts_Validate(t *testing.T) {
106
107
107
108
wantedErrMsg : "cannot specify both --profile and --aws-session-token" ,
108
109
},
110
+ "should err if only one public subnet is set" : {
111
+ inVPCID : "mockID" ,
112
+ inPublicIDs : []string {"mockID" },
113
+
114
+ wantedErrMsg : "at least two public subnets must be imported to enable Load Balancing" ,
115
+ },
116
+ "should err if fewer than two private subnets are set:" : {
117
+ inVPCID : "mockID" ,
118
+ inPublicIDs : []string {"mockID" , "anotherMockID" },
119
+ inPrivateIDs : []string {"mockID" },
120
+
121
+ wantedErrMsg : "at least two private subnets must be imported" ,
122
+ },
123
+ "valid VPC resource import (0 public, 3 private)" : {
124
+ inVPCID : "mockID" ,
125
+ inPublicIDs : []string {},
126
+ inPrivateIDs : []string {"mockID" , "anotherMockID" , "yetAnotherMockID" },
127
+ },
128
+ "valid VPC resource import (3 public, 2 private)" : {
129
+ inVPCID : "mockID" ,
130
+ inPublicIDs : []string {"mockID" , "anotherMockID" , "yetAnotherMockID" },
131
+ inPrivateIDs : []string {"mockID" , "anotherMockID" },
132
+ },
109
133
}
110
134
111
135
for name , tc := range testCases {
@@ -120,8 +144,9 @@ func TestInitEnvOpts_Validate(t *testing.T) {
120
144
CIDR : tc .inVPCCIDR ,
121
145
},
122
146
importVPC : importVPCVars {
123
- PublicSubnetIDs : tc .inPublicIDs ,
124
- ID : tc .inVPCID ,
147
+ PublicSubnetIDs : tc .inPublicIDs ,
148
+ PrivateSubnetIDs : tc .inPrivateIDs ,
149
+ ID : tc .inVPCID ,
125
150
},
126
151
appName : tc .inAppName ,
127
152
profile : tc .inProfileName ,
0 commit comments