Skip to content
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

chore(ci): migrate datastore/functions to new ci #4046

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/config/nodejs-dev.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"datacatalog/quickstart",
"datacatalog/snippets",
"datalabeling",
"datastore/functions",
"dialogflow",
"discoveryengine",
"document-warehouse",
Expand Down
1 change: 0 additions & 1 deletion .github/config/nodejs-prod.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"cloud-sql/sqlserver/tedious", // (untested) TypeError: The "config.server" property is required and must be of type string.
"compute", // GoogleError: The resource 'projects/long-door-651/zones/us-central1-a/disks/disk-from-pool-name' was not found
"dataproc", // GoogleError: Error submitting create cluster request: Multiple validation errors
"datastore/functions", // [ERR_REQUIRE_ESM]: require() of ES Module
"dialogflow-cx", // NOT_FOUND: com.google.apps.framework.request.NotFoundException: Agent 'undefined' does not exist
"dlp", // [ERR_REQUIRE_ESM]: require() of ES Module
"document-ai", // [ERR_REQUIRE_ESM]: require() of ES Module
Expand Down
14 changes: 7 additions & 7 deletions datastore/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
// The value contains a JSON document representing the entity we want to save
if (!req.body.value) {
const err = makeErrorObj('Value');
Expand All @@ -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.
Expand All @@ -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) {
try {
const key = await getKeyFromRequestData(req.body);
const [entity] = await datastore.get(key);
Expand All @@ -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.
Expand All @@ -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) {
// Deletes the entity
// The delete operation will not fail for a non-existent entity, it just
// doesn't delete anything
Expand All @@ -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);
}
};
}
3 changes: 2 additions & 1 deletion datastore/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"type": "module",
"engines": {
"node": ">=16.0.0"
},
Expand All @@ -19,7 +20,7 @@
"devDependencies": {
"@google-cloud/functions-framework": "^3.0.0",
"c8": "^10.0.0",
"child-process-promise": "^2.2.1",
"child-process-promise": "^2.1.3",
"mocha": "^10.0.0",
"node-fetch": "^3.0.0",
"proxyquire": "^2.1.0",
Expand Down
118 changes: 61 additions & 57 deletions datastore/functions/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,26 @@

'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 { fileURLToPath } from 'url';
import { dirname } from 'path';
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 __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const cwd = join(__dirname, '..');
const NAME = 'sampletask1';
const KIND = `Task-${uuid.v4()}`;
const KIND = `Task-${v4()}`;
const VALUE = {
description: 'Buy milk',
};
Expand Down Expand Up @@ -72,14 +76,14 @@ describe('functions/datastore', () => {
body: {},
};
const res = {
status: sinon.stub().returnsThis(),
send: sinon.stub(),
status: stub().returnsThis(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
status: stub().returnsThis(),
status: stub().returnsThis(),

send: stub(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
send: stub(),
send: stub(),

};

await program.set(req, res);
await set(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from program.set to set. Ensure that set is correctly imported.

Suggested change
await set(req, res);
await set(req, res);


assert.ok(res.status.calledWith(500));
assert.ok(res.send.calledWith(errorMsg('Value')));
ok(res.status.calledWith(500));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.status.calledWith(500));
ok(res.status.calledWith(500));

ok(res.send.calledWith(errorMsg('Value')));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.send.calledWith(errorMsg('Value')));
ok(res.send.calledWith(errorMsg('Value')));

});

it('set: Fails without a key', async () => {
Expand All @@ -89,12 +93,12 @@ describe('functions/datastore', () => {
},
};
const res = {
status: sinon.stub().returnsThis(),
send: sinon.stub(),
status: stub().returnsThis(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
status: stub().returnsThis(),
status: stub().returnsThis(),

send: stub(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
send: stub(),
send: stub(),

};
await program.set(req, res);
assert.ok(res.status.calledWith(500));
assert.ok(res.send.calledWith(errorMsg('Key')));
await set(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from program.set to set. Ensure that set is correctly imported.

Suggested change
await set(req, res);
await set(req, res);

ok(res.status.calledWith(500));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.status.calledWith(500));
ok(res.status.calledWith(500));

ok(res.send.calledWith(errorMsg('Key')));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.send.calledWith(errorMsg('Key')));
ok(res.send.calledWith(errorMsg('Key')));

});

it('set: Fails without a kind', async () => {
Expand All @@ -105,14 +109,14 @@ describe('functions/datastore', () => {
},
};
const res = {
status: sinon.stub().returnsThis(),
send: sinon.stub(),
status: stub().returnsThis(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
status: stub().returnsThis(),
status: stub().returnsThis(),

send: stub(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
send: stub(),
send: stub(),

};

await program.set(req, res);
await set(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from program.set to set. Ensure that set is correctly imported.

Suggested change
await set(req, res);
await set(req, res);


assert.ok(res.status.calledWith(500));
assert.ok(res.send.calledWith(errorMsg('Kind')));
ok(res.status.calledWith(500));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.status.calledWith(500));
ok(res.status.calledWith(500));

ok(res.send.calledWith(errorMsg('Kind')));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.send.calledWith(errorMsg('Kind')));
ok(res.send.calledWith(errorMsg('Kind')));

});

it('set: Saves an entity', async () => {
Expand All @@ -125,9 +129,9 @@ describe('functions/datastore', () => {
}),
headers: {'Content-Type': 'application/json'},
});
assert.strictEqual(response.status, 200);
strictEqual(response.status, 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.strictEqual to strictEqual. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
strictEqual(response.status, 200);
strictEqual(response.status, 200);

const body = await response.text();
assert.ok(body.includes(`Entity ${KIND}/${NAME} saved`));
ok(body.includes(`Entity ${KIND}/${NAME} saved`));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(body.includes(`Entity ${KIND}/${NAME} saved`));
ok(body.includes(`Entity ${KIND}/${NAME} saved`));

});
});

Expand Down Expand Up @@ -159,9 +163,9 @@ describe('functions/datastore', () => {
validateStatus: () => true,
});

assert.strictEqual(response.status, 500);
strictEqual(response.status, 500);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.strictEqual to strictEqual. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
strictEqual(response.status, 500);
strictEqual(response.status, 500);

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(
new RegExp(
/(Missing or insufficient permissions.)|(No entity found for key)/
).test(body)
ok(
new RegExp(
/(Missing or insufficient permissions.)|(No entity found for key)/
).test(body)
);

Expand All @@ -177,9 +181,9 @@ describe('functions/datastore', () => {
}),
headers: {'Content-Type': 'application/json'},
});
assert.strictEqual(response.status, 200);
strictEqual(response.status, 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.strictEqual to strictEqual. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
strictEqual(response.status, 200);
strictEqual(response.status, 200);

const body = await response.json();
assert.deepStrictEqual(body, {
deepStrictEqual(body, {
description: 'Buy milk',
});
Comment on lines +186 to 188
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.deepStrictEqual to deepStrictEqual. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
deepStrictEqual(body, {
description: 'Buy milk',
});
deepStrictEqual(body, {
description: 'Buy milk',
});

});
Expand All @@ -189,14 +193,14 @@ describe('functions/datastore', () => {
body: {},
};
const res = {
status: sinon.stub().returnsThis(),
send: sinon.stub(),
status: stub().returnsThis(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
status: stub().returnsThis(),
status: stub().returnsThis(),

send: stub(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
send: stub(),
send: stub(),

};

await program.get(req, res);
await get(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from program.get to get. Ensure that get is correctly imported.

Suggested change
await get(req, res);
await get(req, res);


assert.ok(res.status.calledWith(500));
assert.ok(res.send.calledWith(errorMsg('Key')));
ok(res.status.calledWith(500));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.status.calledWith(500));
ok(res.status.calledWith(500));

ok(res.send.calledWith(errorMsg('Key')));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.send.calledWith(errorMsg('Key')));
ok(res.send.calledWith(errorMsg('Key')));

});

it('get: Fails without a kind', async () => {
Expand All @@ -206,14 +210,14 @@ describe('functions/datastore', () => {
},
};
const res = {
status: sinon.stub().returnsThis(),
send: sinon.stub(),
status: stub().returnsThis(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
status: stub().returnsThis(),
status: stub().returnsThis(),

send: stub(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
send: stub(),
send: stub(),

};

await program.get(req, res);
await get(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from program.get to get. Ensure that get is correctly imported.

Suggested change
await get(req, res);
await get(req, res);


assert.ok(res.status.calledWith(500));
assert.ok(res.send.calledWith(errorMsg('Kind')));
ok(res.status.calledWith(500));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.status.calledWith(500));
ok(res.status.calledWith(500));

ok(res.send.calledWith(errorMsg('Kind')));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.send.calledWith(errorMsg('Kind')));
ok(res.send.calledWith(errorMsg('Kind')));

});
});

Expand All @@ -239,14 +243,14 @@ describe('functions/datastore', () => {
body: {},
};
const res = {
status: sinon.stub().returnsThis(),
send: sinon.stub(),
status: stub().returnsThis(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
status: stub().returnsThis(),
status: stub().returnsThis(),

send: stub(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
send: stub(),
send: stub(),

};

await program.del(req, res);
await del(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from program.del to del. Ensure that del is correctly imported.

Suggested change
await del(req, res);
await del(req, res);


assert.ok(res.status.calledWith(500));
assert.ok(res.send.calledWith(errorMsg('Key')));
ok(res.status.calledWith(500));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.status.calledWith(500));
ok(res.status.calledWith(500));

ok(res.send.calledWith(errorMsg('Key')));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.send.calledWith(errorMsg('Key')));
ok(res.send.calledWith(errorMsg('Key')));

});

it('del: Fails without a kind', async () => {
Expand All @@ -256,14 +260,14 @@ describe('functions/datastore', () => {
},
};
const res = {
status: sinon.stub().returnsThis(),
send: sinon.stub(),
status: stub().returnsThis(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
status: stub().returnsThis(),
status: stub().returnsThis(),

send: stub(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from sinon.stub() to stub(). Ensure that stub is correctly imported from sinon.

Suggested change
send: stub(),
send: stub(),

};

await program.del(req, res);
await del(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from program.del to del. Ensure that del is correctly imported.

Suggested change
await del(req, res);
await del(req, res);


assert.ok(res.status.calledWith(500));
assert.ok(res.send.calledWith(errorMsg('Kind')));
ok(res.status.calledWith(500));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.status.calledWith(500));
ok(res.status.calledWith(500));

ok(res.send.calledWith(errorMsg('Kind')));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(res.send.calledWith(errorMsg('Kind')));
ok(res.send.calledWith(errorMsg('Kind')));

});

it("del: Doesn't fail when entity does not exist", async () => {
Expand All @@ -275,9 +279,9 @@ describe('functions/datastore', () => {
}),
headers: {'Content-Type': 'application/json'},
});
assert.strictEqual(response.status, 200);
strictEqual(response.status, 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.strictEqual to strictEqual. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
strictEqual(response.status, 200);
strictEqual(response.status, 200);

const body = await response.text();
assert.strictEqual(body, `Entity ${KIND}/nonexistent deleted.`);
strictEqual(body, `Entity ${KIND}/nonexistent deleted.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.strictEqual to strictEqual. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
strictEqual(body, `Entity ${KIND}/nonexistent deleted.`);
strictEqual(body, `Entity ${KIND}/nonexistent deleted.`);

});

it('del: Deletes an entity', async () => {
Expand All @@ -289,13 +293,13 @@ describe('functions/datastore', () => {
}),
headers: {'Content-Type': 'application/json'},
});
assert.strictEqual(response.status, 200);
strictEqual(response.status, 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.strictEqual to strictEqual. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
strictEqual(response.status, 200);
strictEqual(response.status, 200);

const body = await response.text();
assert.strictEqual(body, `Entity ${KIND}/${NAME} deleted.`);
strictEqual(body, `Entity ${KIND}/${NAME} deleted.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.strictEqual to strictEqual. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
strictEqual(body, `Entity ${KIND}/${NAME} deleted.`);
strictEqual(body, `Entity ${KIND}/${NAME} deleted.`);


const key = datastore.key([KIND, NAME]);
const [entity] = await datastore.get(key);
assert.ok(!entity);
ok(!entity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change switches from assert.ok to ok. While this isn't necessarily wrong, it's worth considering whether this change improves readability or maintainability. It also changes the style of the test assertions, which should be consistent.

Suggested change
ok(!entity);
ok(!entity);

});
});
});
Loading