-
Notifications
You must be signed in to change notification settings - Fork 2k
chore(ci): migrate datastore/functions to new ci #4080
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 1 commit
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,7 +14,7 @@ | |||||||||||||||||||
|
|
||||||||||||||||||||
| 'use strict'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const {Datastore} = require('@google-cloud/datastore'); | ||||||||||||||||||||
| import {Datastore} from '@google-cloud/datastore'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Instantiates a client | ||||||||||||||||||||
| const datastore = new Datastore(); | ||||||||||||||||||||
|
|
@@ -58,7 +58,7 @@ const getKeyFromRequestData = requestData => { | |||||||||||||||||||
| * @param {object} req.body.value Value to save to Cloud Datastore, e.g. {"description":"Buy milk"} | ||||||||||||||||||||
| * @param {object} res Cloud Function response context. | ||||||||||||||||||||
| */ | ||||||||||||||||||||
| exports.set = async (req, res) => { | ||||||||||||||||||||
| export async function 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. Consider adding a JSDoc comment for the
Suggested change
|
||||||||||||||||||||
| // The value contains a JSON document representing the entity we want to save | ||||||||||||||||||||
| if (!req.body.value) { | ||||||||||||||||||||
| const err = makeErrorObj('Value'); | ||||||||||||||||||||
|
|
@@ -80,7 +80,7 @@ exports.set = async (req, res) => { | |||||||||||||||||||
| console.error(new Error(err.message)); // Add to Stackdriver Error Reporting | ||||||||||||||||||||
| res.status(500).send(err.message); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /** | ||||||||||||||||||||
| * Retrieves a record. | ||||||||||||||||||||
|
|
@@ -94,7 +94,7 @@ exports.set = async (req, res) => { | |||||||||||||||||||
| * @param {string} req.body.key Key at which to retrieve the data, e.g. "sampletask1". | ||||||||||||||||||||
| * @param {object} res Cloud Function response context. | ||||||||||||||||||||
| */ | ||||||||||||||||||||
| exports.get = async (req, res) => { | ||||||||||||||||||||
| export async function 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. Consider adding a JSDoc comment for the /**
* Retrieves a record.
*
* @param {object} req Cloud Function request context.
* @param {object} res Cloud Function response context.
* @returns {Promise<void>}
*/
export async function get(req, res) { |
||||||||||||||||||||
| try { | ||||||||||||||||||||
| const key = await getKeyFromRequestData(req.body); | ||||||||||||||||||||
| const [entity] = await datastore.get(key); | ||||||||||||||||||||
|
|
@@ -110,7 +110,7 @@ exports.get = async (req, res) => { | |||||||||||||||||||
| console.error(new Error(err.message)); // Add to Stackdriver Error Reporting | ||||||||||||||||||||
| res.status(500).send(err.message); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /** | ||||||||||||||||||||
| * Deletes a record. | ||||||||||||||||||||
|
|
@@ -124,7 +124,7 @@ exports.get = async (req, res) => { | |||||||||||||||||||
| * @param {string} req.body.key Key at which to delete data, e.g. "sampletask1". | ||||||||||||||||||||
| * @param {object} res Cloud Function response context. | ||||||||||||||||||||
| */ | ||||||||||||||||||||
| exports.del = async (req, res) => { | ||||||||||||||||||||
| export async function 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. Consider adding a JSDoc comment for the /**
* Deletes a record.
*
* @param {object} req Cloud Function request context.
* @param {object} res Cloud Function response context.
* @returns {Promise<void>}
*/
export async function del(req, res) { |
||||||||||||||||||||
| // Deletes the entity | ||||||||||||||||||||
| // The delete operation will not fail for a non-existent entity, it just | ||||||||||||||||||||
| // doesn't delete anything | ||||||||||||||||||||
|
|
@@ -136,4 +136,4 @@ exports.del = async (req, res) => { | |||||||||||||||||||
| console.error(new Error(err.message)); // Add to Stackdriver Error Reporting | ||||||||||||||||||||
| res.status(500).send(err.message); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,20 +14,20 @@ | |
|
|
||
| '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 assert from 'assert'; | ||
| import {exec as execPromise} from 'child-process-promise'; | ||
| import path from 'path'; | ||
| import uuid from 'uuid'; | ||
| import sinon 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('../'); | ||
|
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. |
||
|
|
||
| const FF_TIMEOUT = 3000; | ||
| const cwd = path.join(__dirname, '..'); | ||
| const NAME = 'sampletask1'; | ||
| const KIND = `Task-${uuid.v4()}`; | ||
| const VALUE = { | ||
|
|
||
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.
Consider using
importfor all dependencies to maintain consistency with ES module syntax. Since thepackage.jsonnow specifiestype: module, it's best to avoidrequirestatements.