-
Notifications
You must be signed in to change notification settings - Fork 2k
chore(ci): migrate datastore/functions to new ci #4046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,22 +14,22 @@ | |||||||||||||||||||
|
|
||||||||||||||||||||
| 'use strict'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const assert = require('assert'); | ||||||||||||||||||||
| const execPromise = require('child-process-promise').exec; | ||||||||||||||||||||
| const path = require('path'); | ||||||||||||||||||||
| const uuid = require('uuid'); | ||||||||||||||||||||
| const sinon = require('sinon'); | ||||||||||||||||||||
| const fetch = require('node-fetch'); | ||||||||||||||||||||
| const waitPort = require('wait-port'); | ||||||||||||||||||||
| const {Datastore} = require('@google-cloud/datastore'); | ||||||||||||||||||||
| import { ok, strictEqual, deepStrictEqual } from 'assert'; | ||||||||||||||||||||
| import { exec as execPromise } from 'child-process-promise'; | ||||||||||||||||||||
| import { join } from 'path'; | ||||||||||||||||||||
| import { v4 } from 'uuid'; | ||||||||||||||||||||
| import { stub } from 'sinon'; | ||||||||||||||||||||
| import fetch from 'node-fetch'; | ||||||||||||||||||||
| import waitPort from 'wait-port'; | ||||||||||||||||||||
| import { Datastore } from '@google-cloud/datastore'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const datastore = new Datastore(); | ||||||||||||||||||||
| const program = require('../'); | ||||||||||||||||||||
| import { set, get, del } from '../'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const FF_TIMEOUT = 3000; | ||||||||||||||||||||
| const cwd = path.join(__dirname, '..'); | ||||||||||||||||||||
| const cwd = join(__dirname, '..'); | ||||||||||||||||||||
| const NAME = 'sampletask1'; | ||||||||||||||||||||
| const KIND = `Task-${uuid.v4()}`; | ||||||||||||||||||||
| const KIND = `Task-${v4()}`; | ||||||||||||||||||||
| const VALUE = { | ||||||||||||||||||||
| description: 'Buy milk', | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
@@ -72,14 +72,14 @@ | |||||||||||||||||||
| body: {}, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| const res = { | ||||||||||||||||||||
| status: sinon.stub().returnsThis(), | ||||||||||||||||||||
| send: sinon.stub(), | ||||||||||||||||||||
| status: stub().returnsThis(), | ||||||||||||||||||||
| send: stub(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| await program.set(req, res); | ||||||||||||||||||||
| await set(req, res); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
|
|
||||||||||||||||||||
| assert.ok(res.status.calledWith(500)); | ||||||||||||||||||||
| assert.ok(res.send.calledWith(errorMsg('Value'))); | ||||||||||||||||||||
| ok(res.status.calledWith(500)); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| ok(res.send.calledWith(errorMsg('Value'))); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| it('set: Fails without a key', async () => { | ||||||||||||||||||||
|
|
@@ -89,12 +89,12 @@ | |||||||||||||||||||
| }, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| const res = { | ||||||||||||||||||||
| status: sinon.stub().returnsThis(), | ||||||||||||||||||||
| send: sinon.stub(), | ||||||||||||||||||||
| status: stub().returnsThis(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| send: stub(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| }; | ||||||||||||||||||||
| await program.set(req, res); | ||||||||||||||||||||
| assert.ok(res.status.calledWith(500)); | ||||||||||||||||||||
| assert.ok(res.send.calledWith(errorMsg('Key'))); | ||||||||||||||||||||
| await set(req, res); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| ok(res.status.calledWith(500)); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| ok(res.send.calledWith(errorMsg('Key'))); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| it('set: Fails without a kind', async () => { | ||||||||||||||||||||
|
|
@@ -105,14 +105,14 @@ | |||||||||||||||||||
| }, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| const res = { | ||||||||||||||||||||
| status: sinon.stub().returnsThis(), | ||||||||||||||||||||
| send: sinon.stub(), | ||||||||||||||||||||
| status: stub().returnsThis(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| send: stub(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| await program.set(req, res); | ||||||||||||||||||||
| await set(req, res); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
|
|
||||||||||||||||||||
| assert.ok(res.status.calledWith(500)); | ||||||||||||||||||||
| assert.ok(res.send.calledWith(errorMsg('Kind'))); | ||||||||||||||||||||
| ok(res.status.calledWith(500)); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| ok(res.send.calledWith(errorMsg('Kind'))); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| it('set: Saves an entity', async () => { | ||||||||||||||||||||
|
|
@@ -125,9 +125,9 @@ | |||||||||||||||||||
| }), | ||||||||||||||||||||
| headers: {'Content-Type': 'application/json'}, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| assert.strictEqual(response.status, 200); | ||||||||||||||||||||
| strictEqual(response.status, 200); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| const body = await response.text(); | ||||||||||||||||||||
| assert.ok(body.includes(`Entity ${KIND}/${NAME} saved`)); | ||||||||||||||||||||
| ok(body.includes(`Entity ${KIND}/${NAME} saved`)); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -159,9 +159,9 @@ | |||||||||||||||||||
| validateStatus: () => true, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| assert.strictEqual(response.status, 500); | ||||||||||||||||||||
| strictEqual(response.status, 500); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| const body = await response.text(); | ||||||||||||||||||||
| assert.ok( | ||||||||||||||||||||
| ok( | ||||||||||||||||||||
| new RegExp( | ||||||||||||||||||||
| /(Missing or insufficient permissions.)|(No entity found for key)/ | ||||||||||||||||||||
| ).test(body) | ||||||||||||||||||||
|
Comment on lines
+168
to
171
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
|
|
@@ -177,9 +177,9 @@ | |||||||||||||||||||
| }), | ||||||||||||||||||||
| headers: {'Content-Type': 'application/json'}, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| assert.strictEqual(response.status, 200); | ||||||||||||||||||||
| strictEqual(response.status, 200); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| const body = await response.json(); | ||||||||||||||||||||
| assert.deepStrictEqual(body, { | ||||||||||||||||||||
| deepStrictEqual(body, { | ||||||||||||||||||||
| description: 'Buy milk', | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
Comment on lines
+186
to
188
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
@@ -189,14 +189,14 @@ | |||||||||||||||||||
| body: {}, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| const res = { | ||||||||||||||||||||
| status: sinon.stub().returnsThis(), | ||||||||||||||||||||
| send: sinon.stub(), | ||||||||||||||||||||
| status: stub().returnsThis(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| send: stub(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| await program.get(req, res); | ||||||||||||||||||||
| await get(req, res); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
|
|
||||||||||||||||||||
| assert.ok(res.status.calledWith(500)); | ||||||||||||||||||||
| assert.ok(res.send.calledWith(errorMsg('Key'))); | ||||||||||||||||||||
| ok(res.status.calledWith(500)); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| ok(res.send.calledWith(errorMsg('Key'))); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| it('get: Fails without a kind', async () => { | ||||||||||||||||||||
|
|
@@ -206,14 +206,14 @@ | |||||||||||||||||||
| }, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| const res = { | ||||||||||||||||||||
| status: sinon.stub().returnsThis(), | ||||||||||||||||||||
| send: sinon.stub(), | ||||||||||||||||||||
| status: stub().returnsThis(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| send: stub(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| await program.get(req, res); | ||||||||||||||||||||
| await get(req, res); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
|
|
||||||||||||||||||||
| assert.ok(res.status.calledWith(500)); | ||||||||||||||||||||
| assert.ok(res.send.calledWith(errorMsg('Kind'))); | ||||||||||||||||||||
| ok(res.status.calledWith(500)); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| ok(res.send.calledWith(errorMsg('Kind'))); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -239,14 +239,14 @@ | |||||||||||||||||||
| body: {}, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| const res = { | ||||||||||||||||||||
| status: sinon.stub().returnsThis(), | ||||||||||||||||||||
| send: sinon.stub(), | ||||||||||||||||||||
| status: stub().returnsThis(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| send: stub(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| await program.del(req, res); | ||||||||||||||||||||
| await del(req, res); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
|
|
||||||||||||||||||||
| assert.ok(res.status.calledWith(500)); | ||||||||||||||||||||
| assert.ok(res.send.calledWith(errorMsg('Key'))); | ||||||||||||||||||||
| ok(res.status.calledWith(500)); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| ok(res.send.calledWith(errorMsg('Key'))); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| it('del: Fails without a kind', async () => { | ||||||||||||||||||||
|
|
@@ -256,14 +256,14 @@ | |||||||||||||||||||
| }, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| const res = { | ||||||||||||||||||||
| status: sinon.stub().returnsThis(), | ||||||||||||||||||||
| send: sinon.stub(), | ||||||||||||||||||||
| status: stub().returnsThis(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| send: stub(), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| await program.del(req, res); | ||||||||||||||||||||
| await del(req, res); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
|
|
||||||||||||||||||||
| assert.ok(res.status.calledWith(500)); | ||||||||||||||||||||
| assert.ok(res.send.calledWith(errorMsg('Kind'))); | ||||||||||||||||||||
| ok(res.status.calledWith(500)); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| ok(res.send.calledWith(errorMsg('Kind'))); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| it("del: Doesn't fail when entity does not exist", async () => { | ||||||||||||||||||||
|
|
@@ -275,9 +275,9 @@ | |||||||||||||||||||
| }), | ||||||||||||||||||||
| headers: {'Content-Type': 'application/json'}, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| assert.strictEqual(response.status, 200); | ||||||||||||||||||||
| strictEqual(response.status, 200); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| const body = await response.text(); | ||||||||||||||||||||
| assert.strictEqual(body, `Entity ${KIND}/nonexistent deleted.`); | ||||||||||||||||||||
| strictEqual(body, `Entity ${KIND}/nonexistent deleted.`); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| it('del: Deletes an entity', async () => { | ||||||||||||||||||||
|
|
@@ -289,13 +289,13 @@ | |||||||||||||||||||
| }), | ||||||||||||||||||||
| headers: {'Content-Type': 'application/json'}, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| assert.strictEqual(response.status, 200); | ||||||||||||||||||||
| strictEqual(response.status, 200); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
| const body = await response.text(); | ||||||||||||||||||||
| assert.strictEqual(body, `Entity ${KIND}/${NAME} deleted.`); | ||||||||||||||||||||
| strictEqual(body, `Entity ${KIND}/${NAME} deleted.`); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change switches from
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| const key = datastore.key([KIND, NAME]); | ||||||||||||||||||||
| const [entity] = await datastore.get(key); | ||||||||||||||||||||
| assert.ok(!entity); | ||||||||||||||||||||
| ok(!entity); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| }); | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }); | ||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change switches from
sinon.stub()tostub(). Ensure thatstubis correctly imported fromsinon.