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

Fix issue with audit-argument-checks after changes on env contexts #13089

Merged
merged 3 commits into from Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/meteor/dynamics_nodejs.js
Expand Up @@ -55,7 +55,7 @@ class EnvironmentVariableAsync {
Meteor._getValueFromAslStore(UPPER_CALL_DYNAMICS_KEY_NAME) || {}
);

if (slotCall) {
if (slotCall != null) {
dynamics[slotCall] = value;
}

Expand Down
57 changes: 40 additions & 17 deletions packages/meteor/dynamics_test.js
Expand Up @@ -20,20 +20,32 @@ if (Meteor.isServer) {
Tinytest.addAsync(
"environment - dynamic variables with two context (server)",
async function (test) {
// Ensure "0" as the dynamic context spread properly
// https://github.com/meteor/meteor/pull/13089
const context0 = new Meteor.EnvironmentVariable();
context0.slot = 0;

const context1 = new Meteor.EnvironmentVariable();
const context2 = new Meteor.EnvironmentVariable();

return context1.withValue(42, async () => {
test.equal(context2.get(), undefined);
await context2.withValue(1, async () => {
await context2.withValue(2, async () => {
test.equal(context2.get(), 2);
return context0.withValue(0, async () => {
test.equal(context1.get(), undefined);
await context1.withValue(42, async () => {
test.equal(context2.get(), undefined);
await context2.withValue(1, async () => {
await context2.withValue(2, async () => {
test.equal(context2.get(), 2);
test.equal(context0.get(), 0);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), 1);
test.equal(context0.get(), 0);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), 1);
test.equal(context2.get(), undefined);
test.equal(context0.get(), 0);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), undefined);
test.equal(context0.get(), 0);
});
}
);
Expand All @@ -44,20 +56,31 @@ if (Meteor.isServer) {
Tinytest.add(
"environment - dynamic variables with two context (client)",
function (test) {
// Ensure "0" as the dynamic context spread properly
// https://github.com/meteor/meteor/pull/13089
const context0 = new Meteor.EnvironmentVariable();
context0.slot = 0;

const context1 = new Meteor.EnvironmentVariable();
const context2 = new Meteor.EnvironmentVariable();

context1.withValue(42, () => {
test.equal(context2.get(), undefined);
context2.withValue(1, () => {
context2.withValue(2, () => {
test.equal(context2.get(), 2);
context0.withValue(0, async () => {
test.equal(context1.get(), undefined);
context1.withValue(42, () => {
test.equal(context2.get(), undefined);
context2.withValue(1, () => {
context2.withValue(2, () => {
test.equal(context2.get(), 2);
test.equal(context0.get(), 0);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), 1);
test.equal(context0.get(), 0);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), 1);
test.equal(context2.get(), undefined);
test.equal(context0.get(), 0);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), undefined);
test.equal(context0.get(), 0);
});
}
);
Expand Down