Detect startup after recent crashes

This commit is contained in:
Fedor Indutny 2022-01-11 12:02:46 -08:00 committed by GitHub
parent 02a732c511
commit 91f1b62bc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 650 additions and 101 deletions

View file

@ -8,7 +8,9 @@ import FormData from 'form-data';
import * as util from 'util';
import * as zlib from 'zlib';
import { upload } from '../../logging/debuglogs';
import * as durations from '../../util/durations';
import { upload } from '../../logging/uploadDebugLog';
import * as logger from '../../logging/log';
const gzip: (_: zlib.InputType) => Promise<Buffer> = util.promisify(zlib.gzip);
@ -39,7 +41,7 @@ describe('upload', () => {
it('makes a request to get the S3 bucket, then uploads it there', async function test() {
assert.strictEqual(
await upload('hello world', '1.2.3'),
await upload({ content: 'hello world', appVersion: '1.2.3', logger }),
'https://debuglogs.org/abc123.gz'
);
@ -47,6 +49,7 @@ describe('upload', () => {
sinon.assert.calledWith(this.fakeGet, 'https://debuglogs.org', {
responseType: 'json',
headers: { 'User-Agent': 'Signal-Desktop/1.2.3 Linux' },
timeout: { request: durations.MINUTE },
});
const compressedContent = await gzip('hello world');
@ -54,6 +57,7 @@ describe('upload', () => {
sinon.assert.calledOnce(this.fakePost);
sinon.assert.calledWith(this.fakePost, 'https://example.com/fake-upload', {
headers: { 'User-Agent': 'Signal-Desktop/1.2.3 Linux' },
timeout: { request: durations.MINUTE },
body: sinon.match((value: unknown) => {
if (!(value instanceof FormData)) {
return false;
@ -76,7 +80,7 @@ describe('upload', () => {
let err: unknown;
try {
await upload('hello world', '1.2.3');
await upload({ content: 'hello world', appVersion: '1.2.3', logger });
} catch (e) {
err = e;
}
@ -102,7 +106,7 @@ describe('upload', () => {
try {
// Again, these should be run serially.
// eslint-disable-next-line no-await-in-loop
await upload('hello world', '1.2.3');
await upload({ content: 'hello world', appVersion: '1.2.3', logger });
} catch (e) {
err = e;
}
@ -115,7 +119,7 @@ describe('upload', () => {
let err: unknown;
try {
await upload('hello world', '1.2.3');
await upload({ content: 'hello world', appVersion: '1.2.3', logger });
} catch (e) {
err = e;
}