@@ -375,7 +375,6 @@ func TestS3BucketModSecret(t *testing.T) {
375
375
"plaintext" : "[{\" apply_server_side_encryption_by_default\" :[{\" kms_master_key_id\" :\" \" ,\" sse_algorithm\" :\" AES256\" }]}]" ,
376
376
}).Equal (t , encyptionsConfig .Inputs ["rule" ])
377
377
integrationTest .Destroy (t )
378
-
379
378
}
380
379
381
380
// When writing out TF files, we need to replace data that is random with a static value
@@ -396,7 +395,7 @@ func cleanRandomDataFromTerraformArtifacts(t *testing.T, tfFilesDir string, repl
396
395
s = strings .ReplaceAll (s , data , replace )
397
396
}
398
397
399
- err = os .WriteFile (path , []byte (s ), 0600 )
398
+ err = os .WriteFile (path , []byte (s ), 0o600 )
400
399
if err != nil {
401
400
return err
402
401
}
@@ -465,7 +464,6 @@ func TestS3BucketWithExplicitProvider(t *testing.T) {
465
464
}
466
465
467
466
func TestIntegration (t * testing.T ) {
468
-
469
467
type testCase struct {
470
468
name string // Must be same as project folder in testdata/programs/ts
471
469
moduleName string
@@ -510,7 +508,7 @@ func TestIntegration(t *testing.T) {
510
508
deleteExpect : map [string ]int {
511
509
"delete" : 9 ,
512
510
},
513
- //TODO: [Fix delete-replace on null_resource](https://github.com/pulumi/pulumi-terraform-module/issues/166)
511
+ // TODO: [Fix delete-replace on null_resource](https://github.com/pulumi/pulumi-terraform-module/issues/166)
514
512
diffNoChangesExpect : map [apitype.OpType ]int {
515
513
apitype .OpType ("replace" ): 1 ,
516
514
apitype .OpType ("same" ): 8 ,
@@ -556,6 +554,62 @@ func TestIntegration(t *testing.T) {
556
554
}
557
555
}
558
556
557
+ // Some resources take minutes to provision and destroy.
558
+ // TestPreview is for such resources, where we only verify that preview works as expected.
559
+ func TestPreview (t * testing.T ) {
560
+ type testCase struct {
561
+ name string // Must be same as project folder in testdata/programs/ts
562
+ moduleName string
563
+ moduleVersion string
564
+ moduleNamespace string
565
+ previewExpect map [apitype.OpType ]int
566
+ }
567
+
568
+ testcases := []testCase {
569
+ {
570
+ name : "rdsmod" ,
571
+ moduleName : "terraform-aws-modules/rds/aws" ,
572
+ moduleVersion : "6.10.0" ,
573
+ moduleNamespace : "rds" ,
574
+ previewExpect : map [apitype.OpType ]int {
575
+ apitype .OpType ("create" ): 6 ,
576
+ },
577
+ },
578
+ }
579
+
580
+ for _ , tc := range testcases {
581
+ tc := tc
582
+ localProviderBinPath := ensureCompiledProvider (t )
583
+ skipLocalRunsWithoutCreds (t )
584
+ t .Run (tc .name , func (t * testing.T ) {
585
+ testProgram := filepath .Join ("testdata" , "programs" , "ts" , tc .name )
586
+ localPath := opttest .LocalProviderPath ("terraform-module" , filepath .Dir (localProviderBinPath ))
587
+ previewTest := pulumitest .NewPulumiTest (t , testProgram , localPath )
588
+
589
+ // Get a prefix for resource names
590
+ prefix := generateTestResourcePrefix ()
591
+
592
+ // Set prefix via config
593
+ previewTest .SetConfig (t , "prefix" , prefix )
594
+
595
+ // Generate package
596
+ pulumiPackageAdd (
597
+ t ,
598
+ previewTest ,
599
+ localProviderBinPath ,
600
+ tc .moduleName ,
601
+ tc .moduleVersion ,
602
+ tc .moduleNamespace )
603
+
604
+ // Preview
605
+ previewResult := previewTest .Preview (t )
606
+ t .Log (previewResult .StdOut )
607
+ t .Log (previewResult .StdErr )
608
+ autogold .Expect (tc .previewExpect ).Equal (t , previewResult .ChangeSummary )
609
+ })
610
+ }
611
+ }
612
+
559
613
func TestDiffDetail (t * testing.T ) {
560
614
// Set up a test Bucket
561
615
localProviderBinPath := ensureCompiledProvider (t )
@@ -577,16 +631,16 @@ func TestDiffDetail(t *testing.T) {
577
631
// Up
578
632
diffDetailTest .Up (t )
579
633
580
- //Change program to remove the module input `server_side_encryption_configuration`
634
+ // Change program to remove the module input `server_side_encryption_configuration`
581
635
diffDetailTest .UpdateSource (t , filepath .Join ("testdata" , "programs" , "ts" , "s3bucketmod" , "updates" ))
582
636
583
637
// Preview
584
638
previewResult := diffDetailTest .Preview (t , optpreview .Diff ())
585
639
586
640
var providerID string
587
641
588
- //Extract the provider URN from state
589
- //TODO: once explicit providers are
642
+ // Extract the provider URN from state
643
+ // TODO: once explicit providers are
590
644
var state map [string ]interface {}
591
645
err := json .Unmarshal (diffDetailTest .ExportStack (t ).Deployment , & state )
592
646
if err != nil {
@@ -923,7 +977,6 @@ func TestDeleteLambda(t *testing.T) {
923
977
} else {
924
978
t .Fatalf ("encountered unexpected error verifying log group was deleted: %v " , err )
925
979
}
926
-
927
980
}
928
981
929
982
// runPreviewWithPlanDiff runs a pulumi preview that creates a plan file
0 commit comments