@@ -36,6 +36,43 @@ func TestAccSpannerInstance_basic(t *testing.T) {
36
36
})
37
37
}
38
38
39
+ func TestAccSpannerInstance_basicUpdateWithProviderDefaultLabels (t * testing.T ) {
40
+ t .Parallel ()
41
+
42
+ idName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (t , 10 ))
43
+ acctest .VcrTest (t , resource.TestCase {
44
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
45
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
46
+ CheckDestroy : testAccCheckSpannerInstanceDestroyProducer (t ),
47
+ Steps : []resource.TestStep {
48
+ {
49
+ Config : testAccSpannerInstance_basicWithProviderLabel (idName , false ),
50
+ Check : resource .ComposeTestCheckFunc (
51
+ resource .TestCheckResourceAttrSet ("google_spanner_instance.basic" , "state" ),
52
+ ),
53
+ },
54
+ {
55
+ ResourceName : "google_spanner_instance.basic" ,
56
+ ImportState : true ,
57
+ ImportStateVerify : true ,
58
+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
59
+ },
60
+ {
61
+ Config : testAccSpannerInstance_basicWithProviderLabel (idName , true ),
62
+ Check : resource .ComposeTestCheckFunc (
63
+ resource .TestCheckResourceAttrSet ("google_spanner_instance.basic" , "state" ),
64
+ ),
65
+ },
66
+ {
67
+ ResourceName : "google_spanner_instance.basic" ,
68
+ ImportState : true ,
69
+ ImportStateVerify : true ,
70
+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
71
+ },
72
+ },
73
+ })
74
+ }
75
+
39
76
func TestAccSpannerInstance_noNodeCountSpecified (t * testing.T ) {
40
77
t .Parallel ()
41
78
@@ -502,6 +539,34 @@ resource "google_spanner_instance" "basic" {
502
539
` , name , name , processingUnits )
503
540
}
504
541
542
+ func testAccSpannerInstance_basicWithProviderLabel (name string , addLabel bool ) string {
543
+ extraLabel := ""
544
+ if addLabel {
545
+ extraLabel = "\" key2\" = \" value2\" "
546
+ }
547
+ return fmt .Sprintf (`
548
+ provider "google" {
549
+ alias = "with-labels"
550
+ default_labels = {
551
+ %s
552
+ }
553
+ }
554
+
555
+ resource "google_spanner_instance" "basic" {
556
+ provider = google.with-labels
557
+ config = "regional-us-central1"
558
+ name = "%s"
559
+ display_name = "%s"
560
+
561
+ processing_units = 100
562
+
563
+ labels = {
564
+ "key1" = "value1"
565
+ }
566
+ }
567
+ ` , extraLabel , name , name )
568
+ }
569
+
505
570
func testAccSpannerInstance_noNodeCountSpecified (name string ) string {
506
571
return fmt .Sprintf (`
507
572
resource "google_spanner_instance" "basic" {
0 commit comments