Skip to content

Commit

Permalink
refactor for base tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dkurucz committed Feb 14, 2016
1 parent ef61698 commit 36a4c2e
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 52 deletions.
28 changes: 17 additions & 11 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@
*/

module.exports = function(grunt) {
var self = require('./');

self.initConfig(grunt, {
username: process.env.USER,
host: 'localhost',
src: 'test/data/',
dest: process.cwd() + '/test/tmp/'
}, true);

grunt.config.merge({
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
Expand All @@ -30,7 +21,22 @@ module.exports = function(grunt) {

// Before generating any new files, remove any previously-created files.
clean: {
tests: ['test/tmp']
tests: ['test/expected']
},

scp: {
options: {
username: process.env.USER,
host: 'localhost',
},
assets: {
files: [{
cwd: 'test/fixtures/',
src: '**',
filter: 'isFile',
dest: process.cwd() + '/test/tmp/'
}]
},
},

// Unit tests.
Expand Down
39 changes: 0 additions & 39 deletions index.js

This file was deleted.

File renamed without changes.
4 changes: 4 additions & 0 deletions test/fixtures/data-sample-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test file #2 for grunt-scp

.
.
33 changes: 31 additions & 2 deletions test/scp_test.js → test/scp_base_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,46 @@ var grunt = require('grunt');
test.ifError(value)
*/

var data = {
scp: {
options: {
username: process.env.USER,
host: 'localhost',
},
assets: {
files: [{
src: 'test/fixtures/**',
filter: 'isFile',
dest: process.cwd() + '/test/tmp/'
}]
},
}
};

grunt.util._.merge(data, grunt.config.data);
grunt.config.data = data;

var path = require('path');
grunt.loadTasks(path.join(__dirname, '../tasks'));

exports.scp = {
setUp: function(done) {
done();
},
default_options: function(test) {
test.expect(1);
test.expect(2);

var actual = grunt.file.read('test/tmp/data-sample-1.txt');
var expected = grunt.file.read('test/data/data-sample-1.txt');
var expected = grunt.file.read('test/fixtures/data-sample-1.txt');
test.equal(actual, expected, 'data sample #1 sent over scp should equal input file');
actual = grunt.file.read('test/tmp/data-sample-2.txt');
expected = grunt.file.read('test/fixtures/data-sample-2.txt');
test.equal(actual, expected, 'data sample #2 sent over scp should equal input file');

test.done();
},
tearDown: function(done){
grunt.file.delete('test/tmp');
done();
}
};

0 comments on commit 36a4c2e

Please sign in to comment.