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

[CUrlUploaderV2] Migrated legacy test #14182

Merged
merged 3 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 13 additions & 0 deletions Tasks/CUrlUploaderV2/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,17 @@ describe('CUrlUploaderV2 Suite', function () {

done();
});

it('run curl with multiple files', (done: Mocha.Done) => {
const tp = path.join(__dirname, 'L0CurlGoodMultiFiles.js');
const tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();

assert(tr.invokedToolCount == 1, 'should have only run curl');
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

done();
});
});
41 changes: 41 additions & 0 deletions Tasks/CUrlUploaderV2/Tests/L0CurlGoodMultiFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import ma = require('azure-pipelines-task-lib/mock-answer');
import tmrm = require('azure-pipelines-task-lib/mock-run');
import path = require('path');

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

tr.setInput('files', '/some/path/file*');
tr.setInput('username', 'user');
tr.setInput('password', 'pass');
tr.setInput('url', 'ftp://some.ftp.com/');
tr.setInput('redirectStderr', 'true');

// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"which": {
"curl": "/usr/local/bin/curl",
"node": "/usr/local/bin/node"
},
"exec": {
"curl -T {/some/path/file1,/some/path/file2} ftp://some.ftp.com/ --stderr - -u user:pass": {
"code": 0,
"stdout": "curl output here"
}
},
"find": {
"/some/path": [
"/some/path/file1",
"/some/path/file2"
]
},
"match": {
"/some/path/file*": [
"/some/path/file1",
"/some/path/file2"
]
},
};
tr.setAnswers(a);

tr.run();