GoogleCloudPlatform / cloud-spanner-emulator

An open source emulator for Cloud Spanner.
Apache License 2.0
265 stars 44 forks source link

Creating a spanner instance from a Golang unit test? #15

Open Michaelhobo opened 3 years ago

Michaelhobo commented 3 years ago

I'm trying to write a unit test for a Go package using Spanner. If possible, I don't want to include gcloud, because I'd need to pull a static version of gcloud into my Bazel workspace. I pulled in the spanner emulator binary into my workspace, and I'm executing path/to/emulator_main --host_port localhost:12345 from my test. I now need to create an instance - is there a Go api I can use to create an instance? Or, how would you recommend going about this?

Michaelhobo commented 3 years ago

Or, is there a way to pull in just the spanner emulator piece of gcloud? The full unpacked google-cloud-sdk distribution is 421MB on disk!

Michaelhobo commented 3 years ago

Ah never mind, I found the InstanceAdmin Go API here: https://godoc.org/cloud.google.com/go/spanner/admin/instance/apiv1

Can we add this to the docs somewhere? I started here: https://cloud.google.com/spanner/docs/emulator, then follow "Getting Started in Go", where it tells you how to create a database in Go, but not how to create an instance in Go.

I think https://cloud.google.com/spanner/docs/getting-started/go#create_an_instance should have a snippet for how to create an instance in Go.

mohitg1580 commented 1 year ago

@arunmoezhi I think we should close this

gauravpurohit06 commented 1 year ago

We have passed it to documentation team, it will be done for all the client libraries to make it consistent so it's a time consuming task and low priority for now as documentation is already available.