Skip to content

Commit

Permalink
dataproc in dataproc_test
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Jun 20, 2024
1 parent ebf018a commit 28491e7
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/hashicorp/terraform-provider-google/google/envvar"
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
"github.com/hashicorp/terraform-provider-google/google/services/dataproc"

"google.golang.org/api/googleapi"

Expand Down Expand Up @@ -173,6 +174,45 @@ func TestAccDataprocCluster_withAccelerators(t *testing.T) {
})
}

func TestUnitDataprocCluster_LocationDiffSuppress(t *testing.T) {
cases := map[string]struct {
Old, New string
ExpectDiffSuppress bool
}{
"locations to zones": {
Old: "projects/x/locations/y/resource/z",
New: "projects/x/zones/y/resource/z",
ExpectDiffSuppress: true,
},
"regions to locations": {
Old: "projects/x/regions/y/resource/z",
New: "projects/x/locations/y/resource/z",
ExpectDiffSuppress: true,
},
"locations to locations": {
Old: "projects/x/locations/y/resource/z",
New: "projects/x/locations/y/resource/z",
ExpectDiffSuppress: false,
},
"zones to regions": {
Old: "projects/x/zones/y/resource/z",
New: "projects/x/regions/y/resource/z",
ExpectDiffSuppress: false,
},
"different locations": {
Old: "projects/x/locations/a/resource/z",
New: "projects/x/locations/b/resource/z",
ExpectDiffSuppress: false,
},
}

for tn, tc := range cases {
if dataproc.LocationDiffSuppress("policy_uri", tc.Old, tc.New, nil) != tc.ExpectDiffSuppress {
t.Fatalf("bad: %s, '%s' => '%s' expect %t", tn, tc.Old, tc.New, tc.ExpectDiffSuppress)
}
}
}

func testAccCheckDataprocAuxiliaryNodeGroupAccelerator(cluster *dataproc.Cluster, project string) resource.TestCheckFunc {
return func(s *terraform.State) error {
expectedUri := fmt.Sprintf("projects/%s/zones/.*/acceleratorTypes/nvidia-tesla-t4", project)
Expand Down

0 comments on commit 28491e7

Please sign in to comment.