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

FUS feature feedback #11

Merged
merged 5 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions Tasks/AppCenterDistributeV1/Tests/L0ApiRejectsFail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import ma = require('vsts-task-lib/mock-answer');
import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import fs = require('fs');
const Readable = require('stream').Readable

const nock = require('nock');

Expand Down
60 changes: 15 additions & 45 deletions Tasks/AppCenterDistributeV1/Tests/L0FailsHttpStatusNot2xx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import fs = require('fs');
import azureBlobUploadHelper = require('../azure-blob-upload-helper');

var Readable = require('stream').Readable
var Stats = require('fs').Stats
import { mockAzure, mockFs } from './TestHelpers';

var nock = require('nock');

Expand All @@ -15,7 +13,7 @@ let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

tmr.setInput('serverEndpoint', 'MyTestEndpoint');
tmr.setInput('appSlug', 'testuser/testapp');
tmr.setInput('app', '/Users/anastasia.kubova/Downloads/test.ipa');
tmr.setInput('app', '/test/path/to/my.ipa');
tmr.setInput('releaseNotesSelection', 'releaseNotesInput');
tmr.setInput('releaseNotesInput', 'my release notes');
tmr.setInput('isMandatory', 'True');
Expand Down Expand Up @@ -104,6 +102,14 @@ nock('https://example.test')
release_url: 'https://example.upload.test/release_upload',
});

nock('https://example.test')
.patch('/v0.1/apps/testuser/testapp/release_uploads/1', {
status: "aborted",
})
.query(true)
.reply(200, {
});

nock('https://example.test')
.put('/v0.1/apps/testuser/testapp/releases/1')
.query(true)
Expand Down Expand Up @@ -167,59 +173,23 @@ nock('https://example.test')
// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"checkPath" : {
"/Users/anastasia.kubova/Downloads/test.ipa": true,
"/test/path/to/my.ipa": true,
"/test/path/to/mappings.txt": true
},
"findMatch" : {
"/test/path/to/mappings.txt": [
"/test/path/to/mappings.txt"
],
"/Users/anastasia.kubova/Downloads/test.ipa": [
"/Users/anastasia.kubova/Downloads/test.ipa"
"/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.statSync = (s: string) => {
let stat = new Stats;
stat.isFile = () => {
return !s.toLowerCase().endsWith(".dsym");
}
stat.isDirectory = () => {
return s.toLowerCase().endsWith(".dsym");
}
stat.size = 100;
return stat;
}

let fsos = fs.openSync;
fs.openSync = (path: string, flags: string) => {
if (path.endsWith(".ipa")){
return 1234567.89;
}
return fsos(path, flags);
};

let fsrs = fs.readSync;
fs.readSync = (fd: number, buffer: Buffer, offset: number, length: number, position: number)=> {
if (fd == 1234567.89) {
buffer = new Buffer(100);
return;
}
return fsrs(fd, buffer, offset, length, position);
};
mockFs();

azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => {
return Promise.resolve();
}
mockAzure();

tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper);
tmr.registerMock('fs', fs);
Expand Down
4 changes: 0 additions & 4 deletions Tasks/AppCenterDistributeV1/Tests/L0MultipleIpaFail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
import ma = require('vsts-task-lib/mock-answer');
import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import fs = require('fs');
const Readable = require('stream').Readable

const nock = require('nock');

const taskPath = path.join(__dirname, '..', 'appcenterdistribute.js');
const tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
Expand Down
124 changes: 7 additions & 117 deletions Tasks/AppCenterDistributeV1/Tests/L0NoSymbolsConditionallyPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import ma = require('vsts-task-lib/mock-answer');
import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import fs = require('fs');
const Readable = require('stream').Readable
const Stats = require('fs').Stats
import { basicSetup, mockFs } from './TestHelpers';

const nock = require('nock');

Expand All @@ -15,89 +14,13 @@ process.env['VSMOBILECENTERUPLOAD_CONTINUEIFSYMBOLSNOTFOUND']='true';

tmr.setInput('serverEndpoint', 'MyTestEndpoint');
tmr.setInput('appSlug', 'testuser/testapp');
tmr.setInput('app', '/test/path/to/one.ipa');
tmr.setInput('app', '/test/path/to/my.ipa');
tmr.setInput('releaseNotesSelection', 'releaseNotesInput');
tmr.setInput('releaseNotesInput', 'my release notes');
tmr.setInput('symbolsType', 'Apple');
tmr.setInput('dsymPath', '/test/path/to/symbols.dSYM');

nock('https://example.test')
.patch('/v0.1/apps/testuser/testapp/releases/1')
.query(true)
.reply(200);

nock('https://example.test')
.post('/v0.1/apps/testuser/testapp/uploads/releases')
.query(true)
.reply(201, {
id: 1,
upload_url: "https://upload.example.test/upload/upload_chunk/1",
package_asset_id: 1,
upload_domain: 'https://example.upload.test/release_upload',
url_encoded_token: "fdsf"
});

nock('https://example.upload.test')
.post('/release_upload/upload/upload_chunk/1')
.query(true)
.reply(200, {

});

nock('https://example.upload.test')
.post('/release_upload/upload/finished/1')
.query(true)
.reply(200, {
error: false,
state: "Done",
});

nock('https://example.test')
.get('/v0.1/apps/testuser/testapp/uploads/releases/1')
.query(true)
.reply(200, {
release_distinct_id: 1,
upload_status: "readyToBePublished",
});

nock('https://example.test')
.patch('/v0.1/apps/testuser/testapp/uploads/releases/1', {
upload_status: "committed",
})
.query(true)
.reply(200, {
upload_status: "committed",
release_url: 'https://example.upload.test/release_upload',
});

nock('https://example.test')
.patch('/v0.1/apps/testuser/testapp/uploads/releases/1', {
upload_status: "uploadFinished",
})
.query(true)
.reply(200, {
upload_status: "uploadFinished",
release_url: 'https://example.upload.test/release_upload',
});

nock('https://example.upload.test')
.post('/release_upload/upload/set_metadata/1')
.query(true)
.reply(200, {
resume_restart: false,
chunk_list: [1],
chunk_size: 100,
blob_partitions: 1
});

//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'
});
basicSetup();

//make it available
nock('https://example.test')
Expand All @@ -111,56 +34,23 @@ nock('https://example.test')
// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"findMatch": {
"/test/path/to/one.ipa": [
"/test/path/to/one.ipa"
"/test/path/to/my.ipa": [
"/test/path/to/my.ipa"
],
"/test/path/to/symbols.dSYM": [
"/test/path/to/symbols.dSYM"
]
},
"checkPath" : {
"/test/path/to/one.ipa": true
"/test/path/to/my.ipa": true
},
"exist": {
"/test/path/to/symbols.dSYM": false
}
};
tmr.setAnswers(a);

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

return stream;
};

fs.statSync = (s) => {
let stat = new Stats;
stat.isFile = () => {
return true;
}

stat.size = 100;
return stat;
}

let fsos = fs.openSync;
fs.openSync = (path: string, flags: string) => {
if (path.endsWith("one.ipa")){
return 1234567.89;
}
return fsos(path, flags);
};

let fsrs = fs.readSync;
fs.readSync = (fd: number, buffer: Buffer, offset: number, length: number, position: number)=> {
if (fd==1234567.89) {
buffer = new Buffer(100);
return;
}
return fsrs(fd, buffer, offset, length, position);
};
mockFs();

tmr.registerMock('fs', fs);

Expand Down
4 changes: 0 additions & 4 deletions Tasks/AppCenterDistributeV1/Tests/L0NoSymbolsFails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
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 nock = require('nock');

let taskPath = path.join(__dirname, '..', 'appcenterdistribute.js');
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
Expand Down
50 changes: 3 additions & 47 deletions Tasks/AppCenterDistributeV1/Tests/L0OneIpaPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import fs = require('fs');
import azureBlobUploadHelper = require('../azure-blob-upload-helper');
import { basicSetup } from './TestHelpers';

var Readable = require('stream').Readable
var Stats = require('fs').Stats
import { basicSetup, mockFs, mockAzure } from './TestHelpers';

var nock = require('nock');

Expand Down Expand Up @@ -61,50 +58,9 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tmr.setAnswers(a);

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

return stream;
};

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

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

return stat;
};

let fsos = fs.openSync;
fs.openSync = (path: string, flags: string) => {
if (path.endsWith("my.ipa")){
return 1234567.89;
}
return fsos(path, flags);
};

let fsrs = fs.readSync;
fs.readSync = (fd: number, buffer: Buffer, offset: number, length: number, position: number)=> {
if (fd==1234567.89) {
buffer = new Buffer(100);
return;
}
return fsrs(fd, buffer, offset, length, position);
};

fs.lstatSync = fs.statSync;
mockFs();

azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => {
return Promise.resolve();
}
mockAzure();

tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper);
tmr.registerMock('fs', fs);
Expand Down
9 changes: 2 additions & 7 deletions Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import fs = require('fs');
import azureBlobUploadHelper = require('../azure-blob-upload-helper');
import { basicSetup, mockFs } from './TestHelpers';

const Readable = require('stream').Readable
const Stats = require('fs').Stats
import { basicSetup, mockFs, mockAzure } from './TestHelpers';

const nock = require('nock');

Expand Down Expand Up @@ -76,9 +73,7 @@ tmr.setAnswers(a);

mockFs();

azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => {
return Promise.resolve();
}
mockAzure();

tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper);
tmr.registerMock('fs', fs);
Expand Down
Loading