Skip to content

Commit

Permalink
test: mock throws when no user
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Nov 2, 2023
1 parent 9fcb206 commit 599f23c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,11 @@ export class TestContext {
})
);

this.SANDBOX.stub(User.prototype, 'retrieve').callsFake(
// @ts-expect-error the real method guarantees a user, but find might not return one
(username): Promise<UserFields | undefined> => Promise.resolve(mockUsers.find((org) => org.username === username))
);
this.SANDBOX.stub(User.prototype, 'retrieve').callsFake((username): Promise<UserFields> => {
const user = mockUsers.find((org) => org.username === username);
if (!user) throw new SfError('User not found', 'UserNotFoundError');
return Promise.resolve(user);
});

const retrieveContents = async function (this: { path: string }): Promise<{ usernames?: string[] }> {
const orgId = basename(this.path.replace('.json', ''));
Expand Down

4 comments on commit 599f23c

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

Logger Benchmarks - ubuntu-latest

Benchmark suite Current: 599f23c Previous: 9fcb206 Ratio
Child logger creation 685704 ops/sec (±2.55%) 412810 ops/sec (±13.76%) 0.60
Logging a string on root logger 831614 ops/sec (±9.05%) 537411 ops/sec (±9.94%) 0.65
Logging an object on root logger 605460 ops/sec (±5.52%) 285532 ops/sec (±15.92%) 0.47
Logging an object with a message on root logger 4145 ops/sec (±223.07%) 191690 ops/sec (±23.68%) 46.25
Logging an object with a redacted prop on root logger 478514 ops/sec (±9.91%) 180328 ops/sec (±19.31%) 0.38
Logging a nested 3-level object on root logger 349691 ops/sec (±7.35%) 141407 ops/sec (±20.92%) 0.40

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Logger Benchmarks - ubuntu-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 599f23c Previous: 9fcb206 Ratio
Logging an object with a message on root logger 4145 ops/sec (±223.07%) 191690 ops/sec (±23.68%) 46.25

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

Logger Benchmarks - windows-latest

Benchmark suite Current: 599f23c Previous: 9fcb206 Ratio
Child logger creation 402157 ops/sec (±1.21%) 560868 ops/sec (±0.91%) 1.39
Logging a string on root logger 499448 ops/sec (±8.89%) 775020 ops/sec (±5.51%) 1.55
Logging an object on root logger 226844 ops/sec (±35.26%) 527407 ops/sec (±8.26%) 2.32
Logging an object with a message on root logger 149081 ops/sec (±24.82%) 16870 ops/sec (±184.85%) 0.11
Logging an object with a redacted prop on root logger 178673 ops/sec (±28.64%) 399750 ops/sec (±20.25%) 2.24
Logging a nested 3-level object on root logger 105730 ops/sec (±28.07%) 285018 ops/sec (±7.36%) 2.70

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Logger Benchmarks - windows-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 599f23c Previous: 9fcb206 Ratio
Logging an object on root logger 226844 ops/sec (±35.26%) 527407 ops/sec (±8.26%) 2.32
Logging an object with a redacted prop on root logger 178673 ops/sec (±28.64%) 399750 ops/sec (±20.25%) 2.24
Logging a nested 3-level object on root logger 105730 ops/sec (±28.07%) 285018 ops/sec (±7.36%) 2.70

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.