Skip to content

Commit

Permalink
Merge pull request #56 from jeffyoung/master
Browse files Browse the repository at this point in the history
Begin using fastlane tools
  • Loading branch information
Jeff Young authored Jan 6, 2017
2 parents 215baa1 + 6883ee1 commit d4fbd3c
Show file tree
Hide file tree
Showing 51 changed files with 1,241 additions and 820 deletions.
43 changes: 31 additions & 12 deletions Tasks/app-store-promote/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('app-store-promote L0 Suite', function () {
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.succeeded, 'task should have succeeded');

done();
Expand All @@ -52,6 +53,7 @@ describe('app-store-promote L0 Suite', function () {
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.succeeded, 'task should have succeeded');

done();
Expand Down Expand Up @@ -90,8 +92,8 @@ describe('app-store-promote L0 Suite', function () {
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.ran('deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true --force'), 'deliver with the latest build should have been run.');
assert(tr.invokedToolCount === 2, 'should have run both gem and deliver.');
assert(tr.ran('fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true --force'), 'fastlane deliver with the latest build should have been run.');
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

Expand All @@ -105,8 +107,8 @@ describe('app-store-promote L0 Suite', function () {
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.ran('deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true --automatic_release --force'), 'deliver with auto release should have been run.');
assert(tr.invokedToolCount === 2, 'should have run both gem and deliver.');
assert(tr.ran('fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true --automatic_release --force'), 'fastlane deliver with auto release should have been run.');
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

Expand All @@ -120,8 +122,8 @@ describe('app-store-promote L0 Suite', function () {
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.ran('deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true -q teamId --force'), 'deliver with team id should have been run.');
assert(tr.invokedToolCount === 2, 'should have run both gem and deliver.');
assert(tr.ran('fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true -q teamId --force'), 'fastlane deliver with team id should have been run.');
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

Expand All @@ -135,8 +137,8 @@ describe('app-store-promote L0 Suite', function () {
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.ran('deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true -r teamName --force'), 'deliver with team name should have been run.');
assert(tr.invokedToolCount === 2, 'should have run both gem and deliver.');
assert(tr.ran('fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true -r teamName --force'), 'fastlane deliver with team name should have been run.');
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

Expand All @@ -150,8 +152,8 @@ describe('app-store-promote L0 Suite', function () {
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.ran('deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true -q teamId -r teamName --force'), 'deliver with team id and team name should have been run.');
assert(tr.invokedToolCount === 2, 'should have run both gem and deliver.');
assert(tr.ran('fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true -q teamId -r teamName --force'), 'fastlane deliver with team id and team name should have been run.');
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

Expand All @@ -165,12 +167,29 @@ describe('app-store-promote L0 Suite', function () {
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.ran('deliver submit_build -u creds-username -a com.microsoft.test.appId -n 42 --skip_binary_upload true --skip_metadata true --skip_screenshots true --force'), 'deliver with build number should have been run.');
assert(tr.invokedToolCount === 2, 'should have run both gem and deliver.');
assert(tr.ran('fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId -n 42 --skip_binary_upload true --skip_metadata true --skip_screenshots true --force'), 'fastlane deliver with build number should have been run.');
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

done();
});

it('custom GEM_CACHE environment variable', (done:MochaDone) => {
this.timeout(1000);

//L0GemCacheEnvVar.ts sets the GEM_CACHE env var and expects it to be used when fastlane is updated.
let tp = path.join(__dirname, 'L0GemCacheEnvVar.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.ran('fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId -n 42 --skip_binary_upload true --skip_metadata true --skip_screenshots true --force'), 'fastlane deliver with build number should have been run.');
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran('/usr/bin/gem update fastlane -i /usr/bin/customGemCache'));

done();
});

});
50 changes: 29 additions & 21 deletions Tasks/app-store-promote/Tests/L0BuildNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,40 @@ tmr.setInput('chooseBuild', 'Specify');

tmr.setInput('buildNumber', '42');

// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers> {
'which': {
'ruby': '/usr/bin/ruby',
'gem': '/usr/bin/gem',
'deliver': '/usr/bin/deliver',
'pilot': '/usr/bin/pilot'
process.env['MOCK_NORMALIZE_SLASHES'] = true;
process.env['HOME'] = '/usr/bin';
let gemCache: string = '/usr/bin/.gem-cache';

//construct a string that is JSON, call JSON.parse(string), send that to ma.TaskLibAnswers
let myAnswers: string = `{
"which": {
"ruby": "/usr/bin/ruby",
"gem": "/usr/bin/gem",
"fastlane": "/usr/bin/fastlane"
},
'checkPath' : {
'/usr/bin/ruby': true,
'/usr/bin/gem': true,
'/usr/bin/deliver': true,
'/usr/bin/pilot': true
"checkPath" : {
"/usr/bin/ruby": true,
"/usr/bin/gem": true,
"/usr/bin/fastlane": true
},
'exec': {
'/usr/bin/gem install deliver': {
'code': 0,
'stdout': '1 gem installed'
"exec": {
"/usr/bin/gem install fastlane": {
"code": 0,
"stdout": "1 gem installed"
},
"/usr/bin/gem update fastlane -i ${gemCache}": {
"code": 0,
"stdout": "1 gem installed"
},
'deliver submit_build -u creds-username -a com.microsoft.test.appId -n 42 --skip_binary_upload true --skip_metadata true --skip_screenshots true --force': {
'code': 0,
'stdout': 'consider it delivered!'
"fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId -n 42 --skip_binary_upload true --skip_metadata true --skip_screenshots true --force": {
"code": 0,
"stdout": "consider it delivered!"
}
}
};
tmr.setAnswers(a);
}`;
let json: any = JSON.parse(myAnswers);
// Cast the json blob into a TaskLibAnswers
tmr.setAnswers(<ma.TaskLibAnswers>json);

// This is how you can mock NPM packages...
os.platform = () => {
Expand Down
65 changes: 65 additions & 0 deletions Tasks/app-store-promote/Tests/L0GemCacheEnvVar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

import ma = require('vsts-task-lib/mock-answer');
import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import os = require('os');

let taskPath = path.join(__dirname, '..', 'app-store-promote.js');
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

tmr.setInput('authType', 'UserAndPass');
tmr.setInput('username', 'creds-username');
tmr.setInput('password', 'creds-password');
tmr.setInput('appIdentifier', 'com.microsoft.test.appId');
tmr.setInput('chooseBuild', 'Specify');

tmr.setInput('buildNumber', '42');

process.env['MOCK_NORMALIZE_SLASHES'] = true;
process.env['GEM_CACHE'] = '/usr/bin/customGemCache';
//process.env['HOME'] = '/usr/bin';
let gemCache: string = process.env['GEM_CACHE'];

//construct a string that is JSON, call JSON.parse(string), send that to ma.TaskLibAnswers
let myAnswers: string = `{
"which": {
"ruby": "/usr/bin/ruby",
"gem": "/usr/bin/gem",
"fastlane": "/usr/bin/fastlane"
},
"checkPath" : {
"/usr/bin/ruby": true,
"/usr/bin/gem": true,
"/usr/bin/fastlane": true
},
"exec": {
"/usr/bin/gem install fastlane": {
"code": 0,
"stdout": "1 gem installed"
},
"/usr/bin/gem update fastlane -i ${gemCache}": {
"code": 0,
"stdout": "1 gem installed"
},
"fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId -n 42 --skip_binary_upload true --skip_metadata true --skip_screenshots true --force": {
"code": 0,
"stdout": "consider it delivered!"
}
}
}`;
let json: any = JSON.parse(myAnswers);
// Cast the json blob into a TaskLibAnswers
tmr.setAnswers(<ma.TaskLibAnswers>json);

// This is how you can mock NPM packages...
os.platform = () => {
return 'darwin';
};
tmr.registerMock('os', os);

tmr.run();
50 changes: 29 additions & 21 deletions Tasks/app-store-promote/Tests/L0LatestBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,40 @@ tmr.setInput('appIdentifier', 'com.microsoft.test.appId');

tmr.setInput('chooseBuild', 'Latest');

// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers> {
'which': {
'ruby': '/usr/bin/ruby',
'gem': '/usr/bin/gem',
'deliver': '/usr/bin/deliver',
'pilot': '/usr/bin/pilot'
process.env['MOCK_NORMALIZE_SLASHES'] = true;
process.env['HOME'] = '/usr/bin';
let gemCache: string = '/usr/bin/.gem-cache';

//construct a string that is JSON, call JSON.parse(string), send that to ma.TaskLibAnswers
let myAnswers: string = `{
"which": {
"ruby": "/usr/bin/ruby",
"gem": "/usr/bin/gem",
"fastlane": "/usr/bin/fastlane"
},
'checkPath' : {
'/usr/bin/ruby': true,
'/usr/bin/gem': true,
'/usr/bin/deliver': true,
'/usr/bin/pilot': true
"checkPath" : {
"/usr/bin/ruby": true,
"/usr/bin/gem": true,
"/usr/bin/fastlane": true
},
'exec': {
'/usr/bin/gem install deliver': {
'code': 0,
'stdout': '1 gem installed'
"exec": {
"/usr/bin/gem install fastlane": {
"code": 0,
"stdout": "1 gem installed"
},
"/usr/bin/gem update fastlane -i ${gemCache}": {
"code": 0,
"stdout": "1 gem installed"
},
'deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true --force': {
'code': 0,
'stdout': 'consider it delivered!'
"fastlane deliver submit_build -u creds-username -a com.microsoft.test.appId --skip_binary_upload true --skip_metadata true --skip_screenshots true --force": {
"code": 0,
"stdout": "consider it delivered!"
}
}
};
tmr.setAnswers(a);
}`;
let json: any = JSON.parse(myAnswers);
// Cast the json blob into a TaskLibAnswers
tmr.setAnswers(<ma.TaskLibAnswers>json);

// This is how you can mock NPM packages...
os.platform = () => {
Expand Down
10 changes: 2 additions & 8 deletions Tasks/app-store-promote/Tests/L0NoBundleId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,17 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers> {
'which': {
'ruby': '/usr/bin/ruby',
'gem': '/usr/bin/gem',
'deliver': '/usr/bin/deliver',
'pilot': '/usr/bin/pilot'
'deliver': '/usr/bin/deliver'
},
'checkPath' : {
'/usr/bin/ruby': true,
'/usr/bin/gem': true,
'/usr/bin/deliver': true,
'/usr/bin/pilot': true
'/usr/bin/deliver': true
},
'exec': {
'/usr/bin/gem install deliver': {
'code': 0,
'stdout': '1 gem installed'
},
'deliver submit_build -u creds-username': {
'code': 0,
'stdout': 'consider it delivered!'
}
}
};
Expand Down
50 changes: 29 additions & 21 deletions Tasks/app-store-promote/Tests/L0NoChooseBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,40 @@ tmr.setInput('appIdentifier', 'com.microsoft.test.appId');

//tmr.setInput('chooseBuild', 'specify');

// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers> {
'which': {
'ruby': '/usr/bin/ruby',
'gem': '/usr/bin/gem',
'deliver': '/usr/bin/deliver',
'pilot': '/usr/bin/pilot'
process.env['MOCK_NORMALIZE_SLASHES'] = true;
process.env['HOME'] = '/usr/bin';
let gemCache: string = '/usr/bin/.gem-cache';

//construct a string that is JSON, call JSON.parse(string), send that to ma.TaskLibAnswers
let myAnswers: string = `{
"which": {
"ruby": "/usr/bin/ruby",
"gem": "/usr/bin/gem",
"fastlane": "/usr/bin/fastlane"
},
'checkPath' : {
'/usr/bin/ruby': true,
'/usr/bin/gem': true,
'/usr/bin/deliver': true,
'/usr/bin/pilot': true
"checkPath" : {
"/usr/bin/ruby": true,
"/usr/bin/gem": true,
"/usr/bin/fastlane": true
},
'exec': {
'/usr/bin/gem install deliver': {
'code': 0,
'stdout': '1 gem installed'
"exec": {
"/usr/bin/gem install fastlane": {
"code": 0,
"stdout": "1 gem installed"
},
"/usr/bin/gem update fastlane -i ${gemCache}": {
"code": 0,
"stdout": "1 gem installed"
},
'deliver submit_build -u creds-username': {
'code': 0,
'stdout': 'consider it delivered!'
"fastlane deliver submit_build -u creds-username": {
"code": 0,
"stdout": "consider it delivered!"
}
}
};
tmr.setAnswers(a);
}`;
let json: any = JSON.parse(myAnswers);
// Cast the json blob into a TaskLibAnswers
tmr.setAnswers(<ma.TaskLibAnswers>json);

// This is how you can mock NPM packages...
os.platform = () => {
Expand Down
Loading

0 comments on commit d4fbd3c

Please sign in to comment.