项目作者: Sobesednik

项目描述 :
Check if Datastore Emulator is supported by @google-cloud/datastore
高级语言: JavaScript
项目地址: git://github.com/Sobesednik/datastore-emulator-test.git
创建时间: 2017-12-20T17:25:50Z
项目社区:https://github.com/Sobesednik/datastore-emulator-test

开源协议:MIT License

下载


datastore-emulator-test

Check if datastore-emulator is working

setup

  1. const datastore = require('@google-cloud/datastore')
  2. module.exports = async () => {
  3. console.log(process.env.DATASTORE_EMULATOR_HOST)
  4. const client = datastore()
  5. const name = 'Test'
  6. const data = 'abc'
  7. const key = client.key([name, 'Some'])
  8. const entity = {
  9. key,
  10. data,
  11. };
  12. await client.upsert(entity);
  13. }

test

  1. const test = require('../src/')
  2. const TestSuite = {
  3. async 'should connect to the emulator'() {
  4. await test();
  5. },
  6. };
  7. module.exports = TestSuite;

start the emulator

  1. gcloud beta emulators datastore start --no-store-on-disk

run test

  1. $(gcloud beta emulators datastore env-init)
  2. npm t

@google-cloud/datastore@1.3.2 (without default credentials)

  1. test
  2. index.js
  3. localhost:8081
  4. should connect to the emulator
  5. | Error: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information.
  6. | at /datastore-emulator-test/node_modules/google-auth-library/lib/auth/googleauth.js:316:21
  7. | at /datastore-emulator-test/node_modules/google-auth-library/lib/auth/googleauth.js:346:7
  8. | at Request._callback (/datastore-emulator-test/node_modules/google-auth-library/lib/transporters.js:70:30)
  9. | at self.callback (/datastore-emulator-test/node_modules/request/request.js:186:22)
  10. | at Request.onRequestError (/datastore-emulator-test/node_modules/request/request.js:878:8)

@google-cloud/datastore@1.3.0 (without default credentials)

  1. test
  2. index.js
  3. localhost:8081
  4. should connect to the emulator
  5. Executed 1 tests.

@google-cloud/datastore@1.3.2

  1. test
  2. index.js
  3. localhost:8081
  4. should connect to the emulator
  5. Executed 1 tests.

@google-cloud/datastore@1.3.0

  1. test
  2. index.js
  3. localhost:8081
  4. should connect to the emulator
  5. | Error: Connect Failed
  6. | at /datastore-emulator-test/node_modules/grpc/src/client.js:554:15
  7. test > index.js > should connect to the emulator
  8. Error: Connect Failed
  9. at /datastore-emulator-test/node_modules/grpc/src/client.js:554:15
  10. Executed 1 tests: 1 error.

@google-cloud/datastore@1.1.0

  1. test
  2. index.js
  3. localhost:8081
  4. should connect to the emulator
  5. Executed 1 tests.