java-docs-samples icon indicating copy to clipboard operation
java-docs-samples copied to clipboard

compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplate.java has no test and is broken

Open anguillanneuf opened this issue 2 years ago • 3 comments

This snippet is never tested anywhere: compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplate.java

When I tried to run it, I got:

{
  "error": {
    "code": 400,
    "message": "Invalid value for field 'resource.disks[0].initializeParams.diskType': 'pd-balanced'. The URL is malformed.",
    "errors": [
      {
        "message": "Invalid value for field 'resource.disks[0].initializeParams.diskType': 'pd-balanced'. The URL is malformed.",
        "domain": "global",
        "reason": "invalid"
      }
    ]
  }
}

Please update the sample with a test.

anguillanneuf avatar Jul 22 '22 23:07 anguillanneuf

@Sita04 Would you be able to take a look at this? Let me know if I should redirect elsewhere. Thanks!

alicejli avatar Jul 25 '22 13:07 alicejli

Please find the test for the particular snippet here: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java#L104-L108

I'll further evaluate and get back why diskType throws an error.

Sita04 avatar Jul 25 '22 18:07 Sita04

@Sita04 hm, I was expecting to find this test in the test body decorated with @test. There are ways around re-creating the resource if the resource is not there / deleted, for example, in Pub/Sub, we ignore NotFound error during cleanup (https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/test/java/pubsub/AdminIT.java#L121) if a test deletes (https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/test/java/pubsub/AdminIT.java#L278) a resource.

anguillanneuf avatar Jul 29 '22 21:07 anguillanneuf