@@ -372,6 +372,38 @@ func TestAccComputeDisk_deleteDetach(t *testing.T) {
372
372
})
373
373
}
374
374
375
+ func TestAccComputeDisk_computeDiskUserRegex (t * testing.T ) {
376
+
377
+ shouldPass := []string {
378
+
379
+ "https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1/instances/123" ,
380
+ "https://www.googleapis.com/compute/v1/projects/123123/zones/us-central1/instances/123" ,
381
+ "https://www.googleapis.com/compute/v1/projects/hashicorptest.net:project-123/zones/us-central1/instances/123" ,
382
+ "https://www.googleapis.com/compute/v1/projects/123/zones/456/instances/789" ,
383
+ }
384
+
385
+ shouldFail := []string {
386
+ "https://www.googleapis.com/compute/v1/projects/project#/zones/us-central1/instances/123" ,
387
+ "https://www.googleapis.com/compute/v1/projects/project/zones/us-central#/instances/123" ,
388
+ "https://www.googleapis.com/compute/v1/projects/project/zones/us-central1/instances/?" ,
389
+ "https://www.googleapis.com/compute/v1/projects/foo.com:bar:baz/zones/us-central1/instances/?" ,
390
+ "https://www.googleapis.com/compute/v1/projects/foo.com:/zones/us-central1/instances/?" ,
391
+ }
392
+
393
+ for _ , element := range shouldPass {
394
+ if ! computeDiskUserRegex .MatchString (element ) {
395
+ t .Error ("computeDiskUserRegex should match on '" + element + "' but doesn't" )
396
+ }
397
+ }
398
+
399
+ for _ , element := range shouldFail {
400
+ if computeDiskUserRegex .MatchString (element ) {
401
+ t .Error ("computeDiskUserRegex shouldn't match on '" + element + "' but does" )
402
+ }
403
+ }
404
+
405
+ }
406
+
375
407
func testAccCheckComputeDiskDestroy (s * terraform.State ) error {
376
408
config := testAccProvider .Meta ().(* Config )
377
409
0 commit comments