applctv / gcp-scala-datastore

Scala wrapper to Google Cloud Datastore operations
15 stars 16 forks source link

Make Datastore overridable #36

Open jacobg opened 5 years ago

jacobg commented 5 years ago

Currently, DatastoreService is a singleton object that creates a private reference to Google's Datastore object. That means it can't be changed. But for testability, it would be great to replace it with a test version using LocalDatastoreHelper: https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-clients/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java

So probably, it would be a good idea to either make DatastoreService.cloudDataStore public, or better yet, make DatastoreService a class that can be instantiated with a caller-provided Datastore.