-
Notifications
You must be signed in to change notification settings - Fork 103
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
Use builtin library and add test to verify that delay is actually delaying #613
base: master
Are you sure you want to change the base?
Conversation
@@ -25,6 +25,6 @@ export declare class GoogleSheetsAction extends GoogleDriveAction { | |||
retriableFileList(drive: Drive, options: any, attempt: number, webhookId: string): Promise<any>; | |||
flush(buffer: sheets_v4.Schema$BatchUpdateSpreadsheetRequest, sheet: Sheet, spreadsheetId: string, webhookId: string): Promise<import("gaxios").GaxiosResponse<sheets_v4.Schema$BatchUpdateSpreadsheetResponse>>; | |||
flushRetry(buffer: sheets_v4.Schema$BatchUpdateSpreadsheetRequest, sheet: Sheet, spreadsheetId: string, webhookId: string): Promise<import("gaxios").GaxiosResponse<sheets_v4.Schema$BatchUpdateSpreadsheetResponse>>; | |||
protected delay(time: number): Promise<void>; | |||
delay(time: number): Promise<void>; |
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.
What effect are you achieving here?
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.
it doesn't particularly matter and then I can actually test the function
@@ -538,6 +538,15 @@ describe(`${action.constructor.name} unit tests`, () => { | |||
}) | |||
}) | |||
|
|||
describe("delay", () => { | |||
it("will block on await delay", async () => { |
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.
Can you provide more detail for why this is necessary?
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.
the previous implementation, although it looked correct, was not actually delaying retries. I am seeing another area which I missed so I will upload another change to this as well
describe("delay", () => { | ||
it("will block on await delay", async () => { | ||
const start = Date.now() | ||
await action.delay(100) |
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.
What are the units here?
const start = Date.now() | ||
await action.delay(100) | ||
const end = Date.now() | ||
chai.expect(end - start).to.be.greaterThanOrEqual(10) |
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.
What are the units here?
await new Promise<void>((resolve) => { | ||
setTimeout(resolve, time) | ||
}) | ||
async delay(time: number) { |
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.
What are the units here?
Previous Promise didn't appear to actually be applying delays