Skip to content

Commit

Permalink
#893187 - support multiple dSYMs upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRukhlin committed Feb 12, 2017
1 parent e3a2abb commit df3f902
Show file tree
Hide file tree
Showing 13 changed files with 1,328 additions and 85 deletions.
61 changes: 61 additions & 0 deletions Tasks/VSMobileCenterUpload/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('VSMobileCenterUpload L0 Suite', function () {
process.env["ENDPOINT_AUTH_MyTestEndpoint"] = "{\"parameters\":{\"apitoken\":\"mytoken123\"},\"scheme\":\"apitoken\"}";
process.env["ENDPOINT_URL_MyTestEndpoint"] = "https://example.test/v0.1";
process.env["ENDPOINT_AUTH_PARAMETER_MyTestEndpoint_APITOKEN"] = "mytoken123";
process.env["SYSTEM_DEFAULTWORKINGDIRECTORY"]="/agent/1/_work";
});

after(() => {
Expand Down Expand Up @@ -78,6 +79,66 @@ describe('VSMobileCenterUpload L0 Suite', function () {
tr.run();
assert(tr.failed, 'task should have failed');

done()
});

it('Positive path: single file with Include Parent', (done: MochaDone) => {
this.timeout(2000);

let tp = path.join(__dirname, 'L0SymIncludeParent.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.succeeded, 'task should have succeeded');

done()
});

it('Positive path: multiple dSYMs in the same foder', (done: MochaDone) => {
this.timeout(2000);

let tp = path.join(__dirname, 'L0SymMultipleDSYMs_flat_1.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.succeeded, 'task should have succeeded');

done()
});

it('Positive path: multiple dSYMs in parallel foders', (done: MochaDone) => {
this.timeout(2000);

let tp = path.join(__dirname, 'L0SymMultipleDSYMs_flat_2.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.succeeded, 'task should have succeeded');

done()
});

it('Positive path: multiple dSYMs in a tree', (done: MochaDone) => {
this.timeout(2000);

let tp = path.join(__dirname, 'L0SymMultipleDSYMs_tree.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.succeeded, 'task should have succeeded');

done()
});

it('Positive path: a single dSYM', (done: MochaDone) => {
this.timeout(2000);

let tp = path.join(__dirname, 'L0SymMultipleDSYMs_single.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.succeeded, 'task should have succeeded');

done()
})
});
14 changes: 5 additions & 9 deletions Tasks/VSMobileCenterUpload/Tests/L0ApiRejectsFail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ nock('https://example.test')
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"checkPath" : {
"/test/path/to/my.ipa": true
},
"glob" : {
"/test/path/to/my.ipa": [
"/test/path/to/my.ipa"
]
}
};
tmr.setAnswers(a);

tmr.registerMock('./utils.js', {
resolveSinglePath: function(s) {
return s ? s : null;
},
checkAndFixFilePath: function(p, name) {
return p;
}
});

tmr.run();

8 changes: 7 additions & 1 deletion Tasks/VSMobileCenterUpload/Tests/L0MultipleIpaFail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"checkPath" : {
"/test/path/to/one.ipa": true,
"/test/path/to/two.ipa": true
},
"glob" : {
"/test/path/to/*.ipa": [
"/test/path/to/one.ipa",
"/test/path/to/two.ipa"
]
}
};
tmr.setAnswers(a);

tmr.registerMock('./utils.js', {
resolveSinglePath: function(s) {
resolveSinglePath: function(s, b1, b2) {
throw new Error("Matched multiple files");
},
checkAndFixFilePath: function(p, name) {
Expand Down
31 changes: 18 additions & 13 deletions Tasks/VSMobileCenterUpload/Tests/L0OneIpaPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,33 +80,38 @@ nock('https://example.test')
// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"checkPath" : {
"/test/path/to/my.ipa": true
"/test/path/to/my.ipa": true,
"/test/path/to/mappings.txt": true
},
"glob" : {
"/test/path/to/mappings.txt": [
"/test/path/to/mappings.txt"
],
"/test/path/to/my.ipa": [
"/test/path/to/my.ipa"
]
}
};
tmr.setAnswers(a);

tmr.registerMock('./utils.js', {
resolveSinglePath: function(s) {
return s ? s : null;
},
checkAndFixFilePath: function(p, name) {
return p;
}
});

fs.createReadStream = (s) => {
fs.createReadStream = (s: string) => {
let stream = new Readable;
stream.push(s);
stream.push(null);

return stream;
};

fs.statSync = (s) => {
fs.statSync = (s: string) => {
let stat = new Stats;

stat.isFile = () => {
return true;
return !s.toLowerCase().endsWith(".dsym");
}
stat.isDirectory = () => {
return s.toLowerCase().endsWith(".dsym");
}
stat.size = 100;

return stat;
}
Expand Down
172 changes: 172 additions & 0 deletions Tasks/VSMobileCenterUpload/Tests/L0SymIncludeParent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@

import ma = require('vsts-task-lib/mock-answer');
import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import fs = require('fs');
var Readable = require('stream').Readable
var Writable = require('stream').Writable
var Stats = require('fs').Stats

var nock = require('nock');

let taskPath = path.join(__dirname, '..', 'vsmobilecenterupload.js');
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

tmr.setInput('serverEndpoint', 'MyTestEndpoint');
tmr.setInput('appSlug', 'testuser/testapp');
tmr.setInput('app', '/test/path/to/my.ipa');
tmr.setInput('releaseNotesSelection', 'releaseNotesInput');
tmr.setInput('releaseNotesInput', 'my release notes');
tmr.setInput('symbolsType', 'AndroidJava');
tmr.setInput('mappingTxtPath', '/test/path/to/mappings.txt');
tmr.setInput('packParentFolder', 'true');

//prepare upload
nock('https://example.test')
.post('/v0.1/apps/testuser/testapp/release_uploads')
.reply(201, {
upload_id: 1,
upload_url: 'https://example.upload.test/release_upload'
});

//upload
nock('https://example.upload.test')
.post('/release_upload')
.reply(201, {
status: 'success'
});

//finishing upload, commit the package
nock('https://example.test')
.patch('/v0.1/apps/testuser/testapp/release_uploads/1', {
status: 'committed'
})
.reply(200, {
release_url: 'my_release_location'
});

//make it available
nock('https://example.test')
.patch('/my_release_location', {
status: 'available',
distribution_group_id:'00000000-0000-0000-0000-000000000000',
release_notes:'my release notes'
})
.reply(200);

//begin symbol upload
nock('https://example.test')
.post('/v0.1/apps/testuser/testapp/symbol_uploads', {
symbol_type: 'AndroidJava'
})
.reply(201, {
symbol_upload_id: 100,
upload_url: 'https://example.upload.test/symbol_upload',
expiration_date: 1234567
});

//upload symbols
nock('https://example.upload.test')
.put('/symbol_upload')
.reply(201, {
status: 'success'
});

//finishing symbol upload, commit the symbol
nock('https://example.test')
.patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', {
status: 'committed'
})
.reply(200);

// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
'checkPath' : {
'/test/path/to/my.ipa': true,
'/test/path/to/mappings.txt': true,
'/test/path/to': true,
'/test/path/to/f1.txt': true,
'/test/path/to/f2.txt': true,
'/test/path/to/folder': true,
'/test/path/to/folder/f11.txt': true,
'/test/path/to/folder/f12.txt': true
},
'glob' : {
'/test/path/to/mappings.txt': [
'/test/path/to/mappings.txt'
],
'/test/path/to/my.ipa': [
'/test/path/to/my.ipa'
]
}
};
tmr.setAnswers(a);

fs.createReadStream = (s: string) => {
let stream = new Readable;
stream.push(s);
stream.push(null);

return stream;
};

fs.createWriteStream = (s: string) => {
let stream = new Writable;

stream.write = () => {};

return stream;
};

fs.readdirSync = (folder: string) => {
let files: string[] = [];

if (folder === '/test/path/to') {
files = [
'mappings.txt',
'f1.txt',
'f2.txt',
'folder'
]
} else if (folder === '/test/path/to/folder') {
files = [
'f11.txt',
'f12.txt'
]
}

return files;
};

fs.statSync = (s: string) => {
let stat = new Stats;
// s = s.replace("\\", "/");

stat.isFile = () => {
if (s === '/test/path/to') {
return false;
} else if (s === '/test/path/to/folder') {
return false;
} else {
return true;
}
}

stat.isDirectory = () => {
if (s === '/test/path/to') {
return true;
} else if (s === '/test/path/to/folder') {
return true;
} else {
return false;
}
}

stat.size = 100;

return stat;
}
tmr.registerMock('fs', fs);

tmr.run();

Loading

0 comments on commit df3f902

Please sign in to comment.