Skip to content

Commit d5c93fe

Browse files
XiaoningLiuvinjiang
authored andcommitted
Refactred test cases for browsers - drop key based cases from browser testing scope
1 parent d380860 commit d5c93fe

30 files changed

Lines changed: 9135 additions & 20574 deletions

browser/test/blob/blobservice-upload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if (testUtil.isBrowser()) {
3030

3131
describe('BlobServiceUpload', function () {
3232
before(function (done) {
33-
blobService = azure.createBlobService(process.env['AZURE_STORAGE_CONNECTION_STRING']);
33+
blobService = testUtil.getBlobService(azure);
3434
assert.notEqual(null, blobService, 'blobService should not be null');
3535

3636
containerName = suite.getName(containerNamesPrefix);

browser/test/bundle.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,13 @@ var bs = browserify([
3939
path.resolve(__dirname, '../../test/services/file/fileservice-sse-tests.js'),
4040
path.resolve(__dirname, '../../test/services/file/fileservice-tests.js'),
4141
path.resolve(__dirname, '../../test/services/file/fileservice-uploaddownload-tests.js'),
42-
path.resolve(__dirname, '../../test/common/connectionstringparsertests.js'),
43-
path.resolve(__dirname, '../../test/common/secondarytests.js'),
44-
path.resolve(__dirname, '../../test/common/servicesettingstests.js'),
45-
path.resolve(__dirname, '../../test/common/servicestatstests.js'),
46-
path.resolve(__dirname, '../../test/common/sharedkey-tests.js'),
4742
path.resolve(__dirname, '../../test/common/storageserviceclienttests.js'),
48-
path.resolve(__dirname, '../../test/common/storageservicesettingstests.js'),
4943
path.resolve(__dirname, '../../test/common/filters/exponentialretrypolicyfilter-tests.js'),
5044
path.resolve(__dirname, '../../test/common/filters/linearretrypolicyfilter-tests.js'),
5145
path.resolve(__dirname, '../../test/common/util/iso8061date-tests.js'),
5246
path.resolve(__dirname, '../../test/common/util/util-tests.js'),
5347
path.resolve(__dirname, '../../test/common/util/validate-tests.js'),
5448
path.resolve(__dirname, '../../test/azure-tests.js'),
55-
path.resolve(__dirname, '../../test/accountsas-tests.js'),
5649
path.resolve(__dirname, './file/fileservice-upload.js'),
5750
path.resolve(__dirname, './blob/blobservice-upload.js')
5851
], { require: ['https'] }).bundle();

browser/test/file/fileservice-upload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if (testUtil.isBrowser()) {
3030

3131
describe('FileServiceUpload', function () {
3232
before(function (done) {
33-
fileService = azure.createFileService(process.env['AZURE_STORAGE_CONNECTION_STRING']);
33+
fileService = testUtil.getFileService(azure);
3434
assert.notEqual(null, fileService, 'FileService should not be null');
3535

3636
shareName = suite.getName(shareNamesPrefix);

karma.conf.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ module.exports = function (config) {
4040
// environment values MUST be exported or set with same console running "karma start"
4141
// https://www.npmjs.com/package/karma-env-preprocessor
4242
envPreprocessor: [
43-
'AZURE_STORAGE_CONNECTION_STRING',
44-
'AZURE_STORAGE_CONNECTION_STRING_SSE_ENABLED_ACCOUNT',
45-
'AZURE_STORAGE_CONNECTION_STRING_BLOB_ACCOUNT',
46-
'AZURE_STORAGE_CONNECTION_STRING_PREMIUM_ACCOUNT'
43+
'AZURE_ACCOUNT',
44+
'AZURE_SAS'
4745
],
4846

4947
// test results reporter to use

test/azure-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('azure', function () {
148148
assert.strictEqual(queueServiceWithTokenCredential.storageCredentials.tokenCredential.get(), 'renewed');
149149
});
150150

151-
it('NotEmulatedExplicitCredentials', function (done) {
151+
skipBrowser('NotEmulatedExplicitCredentials', function (done) {
152152
// Make sure is not emulated
153153
delete process.env[StorageServiceClientConstants.EnvironmentVariables.EMULATED];
154154

@@ -172,7 +172,7 @@ describe('azure', function () {
172172
done();
173173
});
174174

175-
it('EmulatedExplicitCredentials', function (done) {
175+
skipBrowser('EmulatedExplicitCredentials', function (done) {
176176
// set emulated to true
177177
process.env[StorageServiceClientConstants.EnvironmentVariables.EMULATED] = "true";
178178

test/common/filters/exponentialretrypolicyfilter-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('exponentialretrypolicyfilter-tests', function () {
6262
}
6363
suite.setupSuite(function () {
6464
exponentialRetryPolicyFilter = new ExponentialRetryPolicyFilter();
65-
tableService = azure.createTableService(process.env['AZURE_STORAGE_CONNECTION_STRING']).withFilter(exponentialRetryPolicyFilter);
65+
tableService = testutil.getTableService(azure).withFilter(exponentialRetryPolicyFilter);
6666
done();
6767
});
6868
});

test/common/filters/linearretrypolicyfilter-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('linearretrypolicyfilter-tests', function () {
4848
}
4949
suite.setupSuite(function () {
5050
linearRetryPolicyFilter = new LinearRetryPolicyFilter();
51-
tableService = azure.createTableService(process.env['AZURE_STORAGE_CONNECTION_STRING']).withFilter(linearRetryPolicyFilter);
51+
tableService = testutil.getTableService(azure).withFilter(linearRetryPolicyFilter);
5252
done();
5353
});
5454
});

test/common/storageserviceclienttests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var skipBrowser = testutil.itSkipBrowser();
3333

3434
describe('StorageServiceClientTests', function () {
3535

36-
it('devStore', function (done) {
36+
skipBrowser('devStore', function (done) {
3737
var devStoreCreds = azure.generateDevelopmentStorageCredentials();
3838
var devStoreBlobService = azure.createBlobService(devStoreCreds);
3939

test/common/util/validate-tests.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ var assert = require('assert');
2020
var testutil = require('../../framework/util');
2121
var Validate = require('../../../lib/common/util/validate');
2222

23+
if (!String.prototype.includes) {
24+
String.prototype.includes = function(search, start) {
25+
'use strict';
26+
if (typeof start !== 'number') {
27+
start = 0;
28+
}
29+
30+
if (start + search.length > this.length) {
31+
return false;
32+
} else {
33+
return this.indexOf(search, start) !== -1;
34+
}
35+
};
36+
}
37+
2338
describe('validator-tests', function () {
2439
it('isValidEnumValue should work', function (done) {
2540
Validate.isValidEnumValue('a', ['a', 'b', 'c']).should.be.ok;
@@ -28,7 +43,7 @@ describe('validator-tests', function () {
2843
Validate.isValidEnumValue('d', ['a', 'b', 'c']);
2944
},
3045
function(err) {
31-
return (err instanceof RangeError) && err.message === 'Invalid value: d. Options are: a,b,c.';
46+
return (err instanceof RangeError) && err.message.includes('Invalid value: d. Options are');
3247
}
3348
);
3449
done();
@@ -302,7 +317,7 @@ describe('validator-tests', function () {
302317
Validate.blobTypeIsValid('something');
303318
},
304319
function(err) {
305-
return (err instanceof RangeError) && err.message === 'Invalid value: something. Options are: BlockBlob,PageBlob,AppendBlob.';
320+
return (err instanceof RangeError) && err.message.includes('Invalid value: something. Options are:');
306321
}
307322
);
308323
done();

test/framework/test-suite.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var os = require('os');
2020
var path = require('path');
2121
var guid = require('uuid');
2222
var nockHelper = require('./nock-helper');
23+
var testutil = require('./util');
2324

2425
exports = module.exports = TestSuite;
2526

@@ -50,6 +51,20 @@ function TestSuite(testPrefix, env, forceMocked) {
5051
secure: stripAccessKey,
5152
optional: true
5253
}];
54+
55+
if (testutil.isBrowser()) {
56+
requiredEnvironment = [{
57+
name: 'AZURE_ACCOUNT',
58+
secure: stripAccessKey,
59+
optional: false
60+
},{
61+
name: 'AZURE_SAS',
62+
secure: stripAccessKey,
63+
optional: false
64+
}
65+
]
66+
}
67+
5368
env = env.concat(requiredEnvironment);
5469

5570
this.testPrefix = testPrefix;
@@ -77,6 +92,8 @@ function TestSuite(testPrefix, env, forceMocked) {
7792
process.env['AZURE_STORAGE_CONNECTION_STRING'] = window.__env__['AZURE_STORAGE_CONNECTION_STRING'];
7893
process.env['AZURE_STORAGE_CONNECTION_STRING_SSE_ENABLED_ACCOUNT'] = window.__env__['AZURE_STORAGE_CONNECTION_STRING_SSE_ENABLED_ACCOUNT'];
7994
process.env['AZURE_STORAGE_CONNECTION_STRING_BLOB_ACCOUNT'] = window.__env__['AZURE_STORAGE_CONNECTION_STRING_BLOB_ACCOUNT'];
95+
process.env['AZURE_ACCOUNT'] = window.__env__['AZURE_ACCOUNT'];
96+
process.env['AZURE_SAS'] = window.__env__['AZURE_SAS'];
8097

8198
// Premium blob storage account doesn't support CORS currently
8299
// process.env['AZURE_STORAGE_CONNECTION_STRING_PREMIUM_ACCOUNT'] = window.__env__['AZURE_STORAGE_CONNECTION_STRING_PREMIUM_ACCOUNT'];

0 commit comments

Comments
 (0)