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 2 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';

Check failure on line 17 in datastore/functions/index.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·Datastore·` with `Datastore`

// Instantiates a client
const datastore = new Datastore();
Expand Down Expand Up @@ -58,7 +58,7 @@
* @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 @@
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 @@
* @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 @@
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 @@
* @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 @@
console.error(new Error(err.message)); // Add to Stackdriver Error Reporting
res.status(500).send(err.message);
}
};
}
1 change: 1 addition & 0 deletions 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 Down
114 changes: 57 additions & 57 deletions datastore/functions/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Check failure on line 17 in datastore/functions/test/index.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·ok,·strictEqual,·deepStrictEqual·` with `ok,·strictEqual,·deepStrictEqual`
import { exec as execPromise } from 'child-process-promise';

Check failure on line 18 in datastore/functions/test/index.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·exec·as·execPromise·` with `exec·as·execPromise`
import { join } from 'path';

Check failure on line 19 in datastore/functions/test/index.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·join·` with `join`
import { v4 } from 'uuid';

Check failure on line 20 in datastore/functions/test/index.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·v4·` with `v4`
import { stub } from 'sinon';

Check failure on line 21 in datastore/functions/test/index.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·stub·` with `stub`
import fetch from 'node-fetch';
import waitPort from 'wait-port';
import { Datastore } from '@google-cloud/datastore';

Check failure on line 24 in datastore/functions/test/index.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·Datastore·` with `Datastore`

const datastore = new Datastore();
const program = require('../');
import { set, get, del } from '../';

Check failure on line 27 in datastore/functions/test/index.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·set,·get,·del·` with `set,·get,·del`

const FF_TIMEOUT = 3000;
const cwd = path.join(__dirname, '..');
const cwd = join(__dirname, '..');

Check failure on line 30 in datastore/functions/test/index.test.js

View workflow job for this annotation

GitHub Actions / lint

'__dirname' is not defined
const NAME = 'sampletask1';
const KIND = `Task-${uuid.v4()}`;
const KIND = `Task-${v4()}`;
const VALUE = {
description: 'Buy milk',
};
Expand Down Expand Up @@ -72,14 +72,14 @@
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 +89,12 @@
},
};
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 +105,14 @@
},
};
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 +125,9 @@
}),
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 +159,9 @@
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 +177,9 @@
}),
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 +189,14 @@
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 +206,14 @@
},
};
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 +239,14 @@
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 +256,14 @@
},
};
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 +275,9 @@
}),
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 +289,13 @@
}),
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