@@ -1063,12 +1063,12 @@ func TestStackResourceSpace(t *testing.T) {
1063
1063
})
1064
1064
})
1065
1065
1066
- t .Run ("with GitHub and vendor-specific configuration " , func (t * testing.T ) {
1066
+ t .Run ("with GitHub and Pulumi " , func (t * testing.T ) {
1067
1067
randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
1068
1068
1069
- config := func ( vendorConfig string ) string {
1070
- return fmt . Sprintf ( `
1071
- resource "spacelift_stack" "test" {
1069
+ testSteps ( t , []resource. TestStep {
1070
+ {
1071
+ Config : fmt . Sprintf ( ` resource "spacelift_stack" "test" {
1072
1072
administrative = true
1073
1073
after_apply = ["ls -la", "rm -rf /"]
1074
1074
after_destroy = ["echo 'after_destroy'"]
@@ -1088,14 +1088,11 @@ func TestStackResourceSpace(t *testing.T) {
1088
1088
project_root = "root"
1089
1089
repository = "demo"
1090
1090
runner_image = "custom_image:runner"
1091
- %s
1092
- }
1093
- ` , randomID , vendorConfig )
1094
- }
1095
-
1096
- testSteps (t , []resource.TestStep {
1097
- {
1098
- Config : config (`` ),
1091
+ pulumi {
1092
+ login_url = "s3://bucket"
1093
+ stack_name = "mainpl"
1094
+ }
1095
+ }` , randomID ),
1099
1096
Check : Resource (
1100
1097
resourceName ,
1101
1098
Attribute ("id" , StartsWith ("provider-test-stack" )),
@@ -1132,38 +1129,84 @@ func TestStackResourceSpace(t *testing.T) {
1132
1129
Attribute ("project_root" , Equals ("root" )),
1133
1130
Attribute ("repository" , Equals ("demo" )),
1134
1131
Attribute ("runner_image" , Equals ("custom_image:runner" )),
1135
- ),
1136
- },
1137
- {
1138
- ResourceName : resourceName ,
1139
- ImportState : true ,
1140
- ImportStateVerify : true ,
1141
- },
1142
- {
1143
- Config : config (`pulumi {
1144
- login_url = "s3://bucket"
1145
- stack_name = "mainpl"
1146
- }` ),
1147
- Check : Resource (
1148
- resourceName ,
1149
- Attribute ("id" , StartsWith ("provider-test-stack" )),
1150
1132
Attribute ("pulumi.0.login_url" , Equals ("s3://bucket" )),
1151
1133
Attribute ("pulumi.0.stack_name" , Equals ("mainpl" )),
1152
1134
Attribute ("ansible.#" , Equals ("0" )),
1153
1135
Attribute ("cloudformation.#" , Equals ("0" )),
1154
1136
Attribute ("kubernetes.#" , Equals ("0" )),
1155
1137
),
1156
1138
},
1139
+ })
1140
+ })
1141
+
1142
+ t .Run ("with GitHub and Cloudformation" , func (t * testing.T ) {
1143
+ randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
1144
+
1145
+ testSteps (t , []resource.TestStep {
1157
1146
{
1158
- Config : config (`cloudformation {
1147
+ Config : fmt .Sprintf (`resource "spacelift_stack" "test" {
1148
+ administrative = true
1149
+ after_apply = ["ls -la", "rm -rf /"]
1150
+ after_destroy = ["echo 'after_destroy'"]
1151
+ after_init = ["terraform fmt -check", "tflint"]
1152
+ after_perform = ["echo 'after_perform'"]
1153
+ after_plan = ["echo 'after_plan'"]
1154
+ autodeploy = true
1155
+ autoretry = false
1156
+ before_apply = ["ls -la", "rm -rf /"]
1157
+ before_destroy = ["echo 'before_destroy'"]
1158
+ before_init = ["terraform fmt -check", "tflint"]
1159
+ before_perform = ["echo 'before_perform'"]
1160
+ before_plan = ["echo 'before_plan'"]
1161
+ branch = "master"
1162
+ labels = ["one", "two"]
1163
+ name = "Provider test stack %s"
1164
+ project_root = "root"
1165
+ repository = "demo"
1166
+ runner_image = "custom_image:runner"
1167
+ cloudformation {
1159
1168
entry_template_file = "main.yaml"
1160
1169
region = "eu-central-1"
1161
1170
template_bucket = "s3://bucket"
1162
1171
stack_name = "maincf"
1163
- }` ),
1172
+ }
1173
+ }` , randomID ),
1164
1174
Check : Resource (
1165
1175
resourceName ,
1166
1176
Attribute ("id" , StartsWith ("provider-test-stack" )),
1177
+ Attribute ("administrative" , Equals ("true" )),
1178
+ Attribute ("after_apply.#" , Equals ("2" )),
1179
+ Attribute ("after_apply.0" , Equals ("ls -la" )),
1180
+ Attribute ("after_apply.1" , Equals ("rm -rf /" )),
1181
+ Attribute ("after_destroy.#" , Equals ("1" )),
1182
+ Attribute ("after_destroy.0" , Equals ("echo 'after_destroy'" )),
1183
+ Attribute ("after_init.#" , Equals ("2" )),
1184
+ Attribute ("after_init.0" , Equals ("terraform fmt -check" )),
1185
+ Attribute ("after_init.1" , Equals ("tflint" )),
1186
+ Attribute ("after_perform.#" , Equals ("1" )),
1187
+ Attribute ("after_perform.0" , Equals ("echo 'after_perform'" )),
1188
+ Attribute ("after_plan.#" , Equals ("1" )),
1189
+ Attribute ("after_plan.0" , Equals ("echo 'after_plan'" )),
1190
+ Attribute ("autodeploy" , Equals ("true" )),
1191
+ Attribute ("autoretry" , Equals ("false" )),
1192
+ Attribute ("before_apply.#" , Equals ("2" )),
1193
+ Attribute ("before_apply.0" , Equals ("ls -la" )),
1194
+ Attribute ("before_apply.1" , Equals ("rm -rf /" )),
1195
+ Attribute ("before_destroy.#" , Equals ("1" )),
1196
+ Attribute ("before_destroy.0" , Equals ("echo 'before_destroy'" )),
1197
+ Attribute ("before_init.#" , Equals ("2" )),
1198
+ Attribute ("before_init.0" , Equals ("terraform fmt -check" )),
1199
+ Attribute ("before_init.1" , Equals ("tflint" )),
1200
+ Attribute ("before_perform.#" , Equals ("1" )),
1201
+ Attribute ("before_perform.0" , Equals ("echo 'before_perform'" )),
1202
+ Attribute ("before_plan.#" , Equals ("1" )),
1203
+ Attribute ("before_plan.0" , Equals ("echo 'before_plan'" )),
1204
+ Attribute ("branch" , Equals ("master" )),
1205
+ SetEquals ("labels" , "one" , "two" ),
1206
+ Attribute ("name" , StartsWith ("Provider test stack" )),
1207
+ Attribute ("project_root" , Equals ("root" )),
1208
+ Attribute ("repository" , Equals ("demo" )),
1209
+ Attribute ("runner_image" , Equals ("custom_image:runner" )),
1167
1210
Attribute ("cloudformation.0.entry_template_file" , Equals ("main.yaml" )),
1168
1211
Attribute ("cloudformation.0.region" , Equals ("eu-central-1" )),
1169
1212
Attribute ("cloudformation.0.template_bucket" , Equals ("s3://bucket" )),
@@ -1173,45 +1216,112 @@ func TestStackResourceSpace(t *testing.T) {
1173
1216
Attribute ("kubernetes.#" , Equals ("0" )),
1174
1217
),
1175
1218
},
1219
+ })
1220
+ })
1221
+
1222
+ t .Run ("with GitHub and Kubernetes" , func (t * testing.T ) {
1223
+ randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
1224
+
1225
+ testSteps (t , []resource.TestStep {
1176
1226
{
1177
- Config : config (`kubernetes {}` ),
1178
- Check : Resource (
1179
- resourceName ,
1180
- Attribute ("id" , StartsWith ("provider-test-stack" )),
1181
- Attribute ("kubernetes.0.namespace" , Equals ("" )),
1182
- Attribute ("ansible.#" , Equals ("0" )),
1183
- Attribute ("pulumi.#" , Equals ("0" )),
1184
- Attribute ("cloudformation.#" , Equals ("0" )),
1185
- ),
1186
- },
1187
- {
1188
- Config : config (`kubernetes {
1227
+ Config : fmt .Sprintf (`resource "spacelift_stack" "test" {
1228
+ administrative = true
1229
+ after_apply = ["ls -la", "rm -rf /"]
1230
+ after_destroy = ["echo 'after_destroy'"]
1231
+ after_init = ["terraform fmt -check", "tflint"]
1232
+ after_perform = ["echo 'after_perform'"]
1233
+ after_plan = ["echo 'after_plan'"]
1234
+ autodeploy = true
1235
+ autoretry = false
1236
+ before_apply = ["ls -la", "rm -rf /"]
1237
+ before_destroy = ["echo 'before_destroy'"]
1238
+ before_init = ["terraform fmt -check", "tflint"]
1239
+ before_perform = ["echo 'before_perform'"]
1240
+ before_plan = ["echo 'before_plan'"]
1241
+ branch = "master"
1242
+ labels = ["one", "two"]
1243
+ name = "Provider test stack %s"
1244
+ project_root = "root"
1245
+ repository = "demo"
1246
+ runner_image = "custom_image:runner"
1247
+ kubernetes {
1189
1248
namespace = "myapp-prod"
1190
- }` ),
1249
+ }
1250
+ }` , randomID ),
1191
1251
Check : Resource (
1192
1252
resourceName ,
1193
1253
Attribute ("id" , StartsWith ("provider-test-stack" )),
1254
+ Attribute ("administrative" , Equals ("true" )),
1255
+ Attribute ("after_apply.#" , Equals ("2" )),
1256
+ Attribute ("after_apply.0" , Equals ("ls -la" )),
1257
+ Attribute ("after_apply.1" , Equals ("rm -rf /" )),
1258
+ Attribute ("after_destroy.#" , Equals ("1" )),
1259
+ Attribute ("after_destroy.0" , Equals ("echo 'after_destroy'" )),
1260
+ Attribute ("after_init.#" , Equals ("2" )),
1261
+ Attribute ("after_init.0" , Equals ("terraform fmt -check" )),
1262
+ Attribute ("after_init.1" , Equals ("tflint" )),
1263
+ Attribute ("after_perform.#" , Equals ("1" )),
1264
+ Attribute ("after_perform.0" , Equals ("echo 'after_perform'" )),
1265
+ Attribute ("after_plan.#" , Equals ("1" )),
1266
+ Attribute ("after_plan.0" , Equals ("echo 'after_plan'" )),
1267
+ Attribute ("autodeploy" , Equals ("true" )),
1268
+ Attribute ("autoretry" , Equals ("false" )),
1269
+ Attribute ("before_apply.#" , Equals ("2" )),
1270
+ Attribute ("before_apply.0" , Equals ("ls -la" )),
1271
+ Attribute ("before_apply.1" , Equals ("rm -rf /" )),
1272
+ Attribute ("before_destroy.#" , Equals ("1" )),
1273
+ Attribute ("before_destroy.0" , Equals ("echo 'before_destroy'" )),
1274
+ Attribute ("before_init.#" , Equals ("2" )),
1275
+ Attribute ("before_init.0" , Equals ("terraform fmt -check" )),
1276
+ Attribute ("before_init.1" , Equals ("tflint" )),
1277
+ Attribute ("before_perform.#" , Equals ("1" )),
1278
+ Attribute ("before_perform.0" , Equals ("echo 'before_perform'" )),
1279
+ Attribute ("before_plan.#" , Equals ("1" )),
1280
+ Attribute ("before_plan.0" , Equals ("echo 'before_plan'" )),
1281
+ Attribute ("branch" , Equals ("master" )),
1282
+ SetEquals ("labels" , "one" , "two" ),
1283
+ Attribute ("name" , StartsWith ("Provider test stack" )),
1284
+ Attribute ("project_root" , Equals ("root" )),
1285
+ Attribute ("repository" , Equals ("demo" )),
1286
+ Attribute ("runner_image" , Equals ("custom_image:runner" )),
1194
1287
Attribute ("kubernetes.0.namespace" , Equals ("myapp-prod" )),
1195
1288
Attribute ("ansible.#" , Equals ("0" )),
1196
1289
Attribute ("pulumi.#" , Equals ("0" )),
1197
1290
Attribute ("cloudformation.#" , Equals ("0" )),
1198
1291
),
1199
1292
},
1293
+ })
1294
+ })
1295
+
1296
+ t .Run ("with GitHub and Ansible" , func (t * testing.T ) {
1297
+ randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
1298
+
1299
+ testSteps (t , []resource.TestStep {
1200
1300
{
1201
- Config : config (`ansible {
1301
+ Config : fmt .Sprintf (`resource "spacelift_stack" "test" {
1302
+ administrative = true
1303
+ after_apply = ["ls -la", "rm -rf /"]
1304
+ after_destroy = ["echo 'after_destroy'"]
1305
+ after_init = ["terraform fmt -check", "tflint"]
1306
+ after_perform = ["echo 'after_perform'"]
1307
+ after_plan = ["echo 'after_plan'"]
1308
+ autodeploy = true
1309
+ autoretry = false
1310
+ before_apply = ["ls -la", "rm -rf /"]
1311
+ before_destroy = ["echo 'before_destroy'"]
1312
+ before_init = ["terraform fmt -check", "tflint"]
1313
+ before_perform = ["echo 'before_perform'"]
1314
+ before_plan = ["echo 'before_plan'"]
1315
+ branch = "master"
1316
+ labels = ["one", "two"]
1317
+ name = "Provider test stack %s"
1318
+ project_root = "root"
1319
+ repository = "demo"
1320
+ runner_image = "custom_image:runner"
1321
+ ansible {
1202
1322
playbook = "main.yml"
1203
- }` ),
1204
- Check : Resource (
1205
- resourceName ,
1206
- Attribute ("id" , StartsWith ("provider-test-stack" )),
1207
- Attribute ("ansible.0.playbook" , Equals ("main.yml" )),
1208
- Attribute ("cloudformation.#" , Equals ("0" )),
1209
- Attribute ("kubernetes.#" , Equals ("0" )),
1210
- Attribute ("pulumi.#" , Equals ("0" )),
1211
- ),
1212
- },
1213
- {
1214
- Config : config (`` ),
1323
+ }
1324
+ }` , randomID ),
1215
1325
Check : Resource (
1216
1326
resourceName ,
1217
1327
Attribute ("id" , StartsWith ("provider-test-stack" )),
@@ -1248,10 +1358,10 @@ func TestStackResourceSpace(t *testing.T) {
1248
1358
Attribute ("project_root" , Equals ("root" )),
1249
1359
Attribute ("repository" , Equals ("demo" )),
1250
1360
Attribute ("runner_image" , Equals ("custom_image:runner" )),
1251
- Attribute ("ansible.# " , Equals ("0 " )),
1361
+ Attribute ("ansible.0.playbook " , Equals ("main.yml " )),
1252
1362
Attribute ("cloudformation.#" , Equals ("0" )),
1253
- Attribute ("pulumi.#" , Equals ("0" )),
1254
1363
Attribute ("kubernetes.#" , Equals ("0" )),
1364
+ Attribute ("pulumi.#" , Equals ("0" )),
1255
1365
),
1256
1366
},
1257
1367
})
0 commit comments