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

[Engineering] Lower time for botbuilder-azure tests #2629

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletions libraries/botbuilder-azure/tests/blobStorage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const reset = (done) => {

const checkEmulator = () => {
if (!fs.existsSync(emulatorPath)) {
console.warn('This test requires Azure Storage Emulator! go to https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator#get-the-storage-emulator to download and install.');
console.warn('These tests require Azure Storage Emulator! go to https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator#get-the-storage-emulator to download and install.');
}
return true;
};
Expand All @@ -54,117 +54,94 @@ describe('BlobStorage - Constructor', function() {

describe('BlobStorage - Base Storage Tests', function() {
before('cleanup', reset);
before('check emulator', checkEmulator);
after('cleanup', reset);

it('return empty object when reading unknown key', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.returnEmptyObjectWhenReadingUnknownKey(storage);

assert.strictEqual(testRan, true);

return nockDone();
});

it('throws when reading null keys', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.handleNullKeysWhenReading(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('throws when writing null keys', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.handleNullKeysWhenWriting(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('does not throw when writing no items', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.doesNotThrowWhenWritingNoItems(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('create an object', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.createObject(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('handle crazy keys', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.handleCrazyKeys(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('update an object', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.updateObject(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('delete an object', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.deleteObject(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('does not throw when deleting an unknown object', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.deleteUnknownObject(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('performs batch operations', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.performBatchOperations(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('proceeds through a waterfall dialog', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode);

const testRan = await StorageBaseTests.proceedsThroughWaterfall(storage);

assert.strictEqual(testRan, true);
return nockDone();
});
});

32 changes: 4 additions & 28 deletions libraries/botbuilder-azure/tests/cosmosDbStorage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getSettings = (partitionKey=undefined) => ({

const checkEmulator = () => {
if (!fs.existsSync(emulatorPath)) {
console.warn('This test requires CosmosDB Emulator! go to https://aka.ms/documentdb-emulator-docs to download and install.');
console.warn('These tests require CosmosDB Emulator! go to https://aka.ms/documentdb-emulator-docs to download and install.');
}
return true;
};
Expand Down Expand Up @@ -198,113 +198,91 @@ describe('CosmosDbStorage - Constructor Tests', function() {

describe('CosmosDbStorage - Base Storage Tests', function() {
before('cleanup', reset);
before('check emulator', checkEmulator);
after('cleanup', reset);

it('return empty object when reading unknown key', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.returnEmptyObjectWhenReadingUnknownKey(storage);

assert.strictEqual(testRan, true);

return nockDone();
});

it('throws when reading null keys', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.handleNullKeysWhenReading(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('throws when writing null keys', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.handleNullKeysWhenWriting(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('does not throw when writing no items', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.doesNotThrowWhenWritingNoItems(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('create an object', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.createObject(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('handle crazy keys', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.handleCrazyKeys(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('update an object', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.updateObject(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('delete an object', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.deleteObject(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('does not throw when deleting an unknown object', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.deleteUnknownObject(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('performs batch operations', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.performBatchOperations(storage);

assert.strictEqual(testRan, true);
return nockDone();
});

it('proceeds through a waterfall dialog', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

const testRan = await StorageBaseTests.proceedsThroughWaterfall(storage);

assert.strictEqual(testRan, true);
Expand All @@ -322,10 +300,10 @@ describe('CosmosDbStorage - Base Storage Tests', function() {
// PartitionKeys are deprecated. Tests are here to ensure backwards compatibility of changes
describe('CosmosDbStorage - PartitionKey Tests', function() {
before('cleanup', reset);
before('check emulator', checkEmulator);
after('cleanup', reset);

it('create and read an object with partitionKey', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

await storage.write(changes);
Expand All @@ -336,7 +314,6 @@ describe('CosmosDbStorage - PartitionKey Tests', function() {
});

it('update an object with partitionKey', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

await storage.write({ keyUpdate: { count: 1 }, Location: partitionKey });
Expand All @@ -355,7 +332,6 @@ describe('CosmosDbStorage - PartitionKey Tests', function() {
});

it('delete an object with partitionKey', async function() {
checkEmulator();
const { nockDone } = await usingNock(this.test, mode, options);

await storage.write(changes);
Expand Down Expand Up @@ -403,4 +379,4 @@ describe('CosmosDbStorage - Offline tests', function() {
const storage = new CosmosDbStorage(getSettings(), policyConfigurator);
await assert.doesNotReject(async () => await storage.delete(null));
});
});
});