spanner-golang-test
A golang unit test example for google spanner, using google spanner emulator provided by cloud-spanner-emulator.
Hopefully, it helps you.
I create this since I can not find the straight-forward example for golang.
Setup
You need spanner emulator running:
docker run -d -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator:1.0.0
Test
Run make test
. The test uses golang test suite, which will do:
- Create spanner instance on google spanner emulator
- Create spanner db on google spanner emulator
- Execute singer-table-ddl
- Truncate
singer
table before test
- Execute test(s)
- Drop database and instance on google spanner emulator
Database creation/drop is done as suggested by in cloud-spanner-emulator README.
Quick Links
Parts of code that might help you: