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 tests #14134

Merged
merged 8 commits into from
Dec 24, 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
39 changes: 35 additions & 4 deletions Tasks/CUrlUploaderV2/Tests/L0.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
import fs = require('fs');
import assert = require('assert');
import path = require('path');
import * as ttm from 'azure-pipelines-task-lib/mock-test';

describe('CUrlUploaderV2 Suite', function () {
before(() => {
this.timeout(parseInt(process.env.TASK_TEST_TIMEOUT) || 20000);

it('runs a curl with single file', (done: Mocha.Done) => {
const tp = path.join(__dirname, 'L0CurlGoodSingleFile.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();
});

after(() => {
it('fails if url (req) input not set', (done: Mocha.Done) => {
const tp = path.join(__dirname, 'L0NoUrl.js');
const tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();

assert(tr.stdOutContained('Input required: url'), 'Should have printed: Input required: url');
assert(tr.failed, 'task should have failed');
assert(tr.invokedToolCount == 0, 'should exit before running curl');

done();
});

it('Does a basic hello world test', function(done: MochaDone) {
// TODO - add real tests
it('fails if files (req) input not set', (done: Mocha.Done) => {
const tp = path.join(__dirname, 'L0NoFiles.js');
const tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();

assert(tr.stdOutContained('Input required: files'), 'Should have printed: Input required: files');
assert(tr.failed, 'task should have failed');
assert(tr.invokedToolCount == 0, 'should exit before running curl');

done();
});
});
32 changes: 32 additions & 0 deletions Tasks/CUrlUploaderV2/Tests/L0CurlGoodSingleFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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/one');
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/one ftp://some.ftp.com/ --stderr - -u user:pass": {
"code": 0,
"stdout": "curl output here"
}
},
"checkPath": {
"/some/path/one": true
}
};
tr.setAnswers(a);

tr.run();
28 changes: 28 additions & 0 deletions Tasks/CUrlUploaderV2/Tests/L0NoFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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('url', 'ftp://some.ftp.com/');

// 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/one ftp://some.ftp.com/ --stderr - -u user:pass": {
"code": 0,
"stdout": "curl output here"
}
},
"checkPath": {
"/some/path/one": true
}
};
tr.setAnswers(a);

tr.run();
28 changes: 28 additions & 0 deletions Tasks/CUrlUploaderV2/Tests/L0NoUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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/one');

// 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/one ftp://some.ftp.com/ --stderr - -u user:pass": {
"code": 0,
"stdout": "curl output here"
}
},
"checkPath": {
"/some/path/one": true
}
};
tr.setAnswers(a);

tr.run();
115 changes: 0 additions & 115 deletions Tests-Legacy/L0/cURLUploader/_suite.ts

This file was deleted.

24 changes: 0 additions & 24 deletions Tests-Legacy/L0/cURLUploader/curlGoodMultiFiles.json

This file was deleted.

15 changes: 0 additions & 15 deletions Tests-Legacy/L0/cURLUploader/curlGoodSingleFile.json

This file was deleted.