@@ -556,6 +556,63 @@ func TestIntegration(t *testing.T) {
556
556
}
557
557
}
558
558
559
+ // Some resources take minutes to provision and destroy.
560
+ // TestPreview is for such resources, where we only verify that preview works as expected.
561
+ func TestPreview (t * testing.T ) {
562
+
563
+ type testCase struct {
564
+ name string // Must be same as project folder in testdata/programs/ts
565
+ moduleName string
566
+ moduleVersion string
567
+ moduleNamespace string
568
+ previewExpect map [apitype.OpType ]int
569
+ }
570
+
571
+ testcases := []testCase {
572
+ {
573
+ name : "rdsmod" ,
574
+ moduleName : "terraform-aws-modules/rds/aws" ,
575
+ moduleVersion : "6.10.0" ,
576
+ moduleNamespace : "rds" ,
577
+ previewExpect : map [apitype.OpType ]int {
578
+ apitype .OpType ("create" ): 6 ,
579
+ },
580
+ },
581
+ }
582
+
583
+ for _ , tc := range testcases {
584
+ tc := tc
585
+ localProviderBinPath := ensureCompiledProvider (t )
586
+ skipLocalRunsWithoutCreds (t )
587
+ t .Run (tc .name , func (t * testing.T ) {
588
+ testProgram := filepath .Join ("testdata" , "programs" , "ts" , tc .name )
589
+ localPath := opttest .LocalProviderPath ("terraform-module" , filepath .Dir (localProviderBinPath ))
590
+ previewTest := pulumitest .NewPulumiTest (t , testProgram , localPath )
591
+
592
+ // Get a prefix for resource names
593
+ prefix := generateTestResourcePrefix ()
594
+
595
+ // Set prefix via config
596
+ previewTest .SetConfig (t , "prefix" , prefix )
597
+
598
+ // Generate package
599
+ pulumiPackageAdd (
600
+ t ,
601
+ previewTest ,
602
+ localProviderBinPath ,
603
+ tc .moduleName ,
604
+ tc .moduleVersion ,
605
+ tc .moduleNamespace )
606
+
607
+ // Preview
608
+ previewResult := previewTest .Preview (t )
609
+ t .Log (previewResult .StdOut )
610
+ t .Log (previewResult .StdErr )
611
+ autogold .Expect (tc .previewExpect ).Equal (t , previewResult .ChangeSummary )
612
+ })
613
+ }
614
+ }
615
+
559
616
func TestDiffDetail (t * testing.T ) {
560
617
// Set up a test Bucket
561
618
localProviderBinPath := ensureCompiledProvider (t )
0 commit comments