Fix testing setup
This commit is contained in:
parent
ae590e6fc8
commit
2e827b6da5
1 changed files with 33 additions and 22 deletions
|
|
@ -129,19 +129,17 @@ export class MockAgent extends MockClient {
|
||||||
options.push(this.enableSyncAction.bind(this));
|
options.push(this.enableSyncAction.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = await this.listFilesRecursively();
|
|
||||||
|
|
||||||
if (files.length > 0) {
|
options.push(
|
||||||
options.push(
|
this.renameFileAction.bind(this),
|
||||||
this.renameFileAction.bind(this, files),
|
this.updateFileAction.bind(this)
|
||||||
this.updateFileAction.bind(this, files)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (this.doDeletes) {
|
if (this.doDeletes) {
|
||||||
options.push(this.deleteFileAction.bind(this, files));
|
options.push(this.deleteFileAction.bind(this));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Math.random() < 0.015 && this.doResets) {
|
if (Math.random() < 0.015 && this.doResets) {
|
||||||
// we can't just queue this up as once it's destroyed, no more method calls can go to SyncClient
|
// we can't just queue this up as once it's destroyed, no more method calls can go to SyncClient
|
||||||
await this.resetClient();
|
await this.resetClient();
|
||||||
|
|
@ -257,22 +255,20 @@ export class MockAgent extends MockClient {
|
||||||
.includes(content);
|
.includes(content);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.doDeletes) {
|
assert(
|
||||||
// assert(
|
found.length <= 1,
|
||||||
// found.length <= 1,
|
`[${this.name}] Content ${content} found in multiple files: ${found.join(", ")}`
|
||||||
// `[${this.name}] Content ${content} found in ${found.join(", ")}`
|
);
|
||||||
// );
|
|
||||||
} else {
|
if (!this.doDeletes) {
|
||||||
assert(
|
assert(
|
||||||
found.length >= 1,
|
found.length >= 1,
|
||||||
`[${this.name}] Content ${content} not found in any files`
|
`[${this.name}] Content ${content} not found in any files`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// assert(
|
|
||||||
// found.length <= 1,
|
|
||||||
// `[${this.name}] Content ${content} found in multiple files: ${found.join(", ")}`
|
|
||||||
// );
|
|
||||||
|
|
||||||
|
if (found.length === 1) {
|
||||||
const [file] = found;
|
const [file] = found;
|
||||||
const fileContent = new TextDecoder().decode(
|
const fileContent = new TextDecoder().decode(
|
||||||
this.files.get(file)
|
this.files.get(file)
|
||||||
|
|
@ -324,7 +320,12 @@ export class MockAgent extends MockClient {
|
||||||
this.lastSyncEnabledState = true;
|
this.lastSyncEnabledState = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async renameFileAction(files: RelativePath[]): Promise<void> {
|
private async renameFileAction(): Promise<void> {
|
||||||
|
const files = await this.listFilesRecursively();
|
||||||
|
if (files.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const file = choose(files);
|
const file = choose(files);
|
||||||
|
|
||||||
// We can't edit files offline that have been updated while offline.
|
// We can't edit files offline that have been updated while offline.
|
||||||
|
|
@ -355,7 +356,12 @@ export class MockAgent extends MockClient {
|
||||||
return this.rename(file, newName, { ignoreSlowFileEvents: true });
|
return this.rename(file, newName, { ignoreSlowFileEvents: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateFileAction(files: RelativePath[]): Promise<void> {
|
private async updateFileAction(): Promise<void> {
|
||||||
|
const files = await this.listFilesRecursively();
|
||||||
|
if (files.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const file = choose(files);
|
const file = choose(files);
|
||||||
|
|
||||||
// We can't edit files offline that have been updated while offline.
|
// We can't edit files offline that have been updated while offline.
|
||||||
|
|
@ -385,7 +391,12 @@ export class MockAgent extends MockClient {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async deleteFileAction(files: RelativePath[]): Promise<void> {
|
private async deleteFileAction(): Promise<void> {
|
||||||
|
const files = await this.listFilesRecursively();
|
||||||
|
if (files.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const file = choose(files);
|
const file = choose(files);
|
||||||
this.client.logger.info(`Decided to delete file ${file}`);
|
this.client.logger.info(`Decided to delete file ${file}`);
|
||||||
return this.delete(file, { ignoreSlowFileEvents: true });
|
return this.delete(file, { ignoreSlowFileEvents: true });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue