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

Add AppVeryor Windows CI configuration #87

Closed
wants to merge 2 commits into from
Closed
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
35 changes: 35 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
environment:
matrix:
- nodejs_version: "4"
- nodejs_version: "5"
- nodejs_version: "6"

platform:
- x86
- x64

# checkout all strings with \r\n
init:
- git config --global core.autocrlf true

# Install scripts. (runs after repo cloning)
install:
# install ImageMagick
- ps: choco install imagemagick -y

# install Node.js
- ps: Install-Product node $env:nodejs_version

# install npm modules
- npm install

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
- npm test

# Don't actually build.
build: off
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
],
"scripts": {
"codacy-coverage": "codacy-coverage",
"cover": "istanbul cover --report lcovonly ./node_modules/.bin/_mocha -- -r test/support/env test/**",
"cover": "istanbul cover --report lcovonly ./node_modules/.bin/_mocha -- -r test/support/env test",
"lint": "eslint index.js test",
"nsp": "nsp check",
"semantic-release": "semantic-release",
"start": "supervisor index.js",
"test": "mocha -b -c --check-leaks -R tap -r test/support/env test/**",
"test:watch": "mocha -w -b -c --check-leaks -R progress -r test/support/env test/**",
"test": "mocha -b -c --check-leaks -R tap -r test/support/env test",
"test:watch": "mocha -w -b -c --check-leaks -R progress -r test/support/env test",
"greenkeeper-postpublish": "greenkeeper-postpublish"
},
"repository": {
Expand Down
40 changes: 24 additions & 16 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const S3 = require('aws-sdk').S3;
const ReadStream = require('fs').ReadStream;
const statSync = require('fs').statSync;
const unlinkSync = require('fs').unlinkSync;
const pathSep = require('path').sep;

const randomPath = require('@starefossen/rand-path');

Expand Down Expand Up @@ -183,14 +184,18 @@ describe('Image', () => {
let image;

beforeEach(() => {
image = new Upload.Image(`${__dirname}/assets/photo.jpg`, {}, upload);
const file = [__dirname, 'assets', 'photo.jpg'].join(pathSep);

image = new Upload.Image(file, {}, upload);
image.upload._randomPath = () => '110ec58a-a0f2-4ac4-8393-c866d813b8d1';
});

describe('constructor', () => {
it('sets default values', () => {
const file = [__dirname, 'assets', 'photo.jpg'].join(pathSep);

assert(image instanceof Upload.Image);
assert.equal(image.src, `${__dirname}/assets/photo.jpg`);
assert.equal(image.src, file);
assert.deepEqual(image.opts, {});
assert(image.upload instanceof Upload);
});
Expand All @@ -206,7 +211,7 @@ describe('Image', () => {
});

it('sets upload key', done => {
const version = { path: '/some/image.jpg' };
const version = { path: [__dirname, 'assets', 'photo.jpg'].join(pathSep) };

image.upload.s3.putObject = (opts) => {
assert.equal(opts.Key, '110ec58a-a0f2-4ac4-8393-c866d813b8d1.jpg');
Expand All @@ -218,7 +223,7 @@ describe('Image', () => {

it('sets upload key suffix', done => {
const version = {
path: '/some/image.jpg',
path: [__dirname, 'assets', 'photo.jpg'].join(pathSep),
suffix: '-small',
};

Expand All @@ -233,7 +238,7 @@ describe('Image', () => {

it('sets upload key format', done => {
const version = {
path: '/some/image.png',
path: [__dirname, 'assets', 'photo.png'].join(pathSep),
};

image.upload.s3.putObject = (opts) => {
Expand All @@ -246,7 +251,7 @@ describe('Image', () => {

it('sets default ACL', done => {
const version = {
path: '/some/image.png',
path: [__dirname, 'assets', 'photo.png'].join(pathSep),
};

image.upload.s3.putObject = (opts) => {
Expand All @@ -259,7 +264,7 @@ describe('Image', () => {

it('sets specific ACL', done => {
const version = {
path: '/some/image.png',
path: [__dirname, 'assets', 'photo.png'].join(pathSep),
awsImageAcl: 'private',
};

Expand All @@ -273,7 +278,7 @@ describe('Image', () => {

it('sets upload body', done => {
const version = {
path: '/some/image.png',
path: [__dirname, 'assets', 'photo.png'].join(pathSep),
};

image.upload.s3.putObject = (opts) => {
Expand All @@ -287,7 +292,7 @@ describe('Image', () => {

it('sets upload content type for png', done => {
const version = {
path: '/some/image.png',
path: [__dirname, 'assets', 'photo.png'].join(pathSep),
};

image.upload.s3.putObject = (opts) => {
Expand All @@ -300,7 +305,7 @@ describe('Image', () => {

it('sets upload content type for jpg', done => {
const version = {
path: '/some/image.jpg',
path: [__dirname, 'assets', 'photo.jpg'].join(pathSep),
};

image.upload.s3.putObject = (opts) => {
Expand All @@ -313,7 +318,7 @@ describe('Image', () => {

it('sets upload expire header for version', done => {
const version = {
path: '/some/image.jpg',
path: [__dirname, 'assets', 'photo.jpg'].join(pathSep),
awsImageExpires: 1234,
};

Expand All @@ -327,7 +332,7 @@ describe('Image', () => {

it('sets upload cache-control header for version', done => {
const version = {
path: '/some/image.jpg',
path: [__dirname, 'assets', 'photo.jpg'].join(pathSep),
awsImageMaxAge: 1234,
};

Expand All @@ -341,7 +346,7 @@ describe('Image', () => {

it('returns etag for uploaded version', done => {
const version1 = {
path: '/some/image.jpg',
path: [__dirname, 'assets', 'photo.jpg'].join(pathSep),
};

const dest = '110ec58a-a0f2-4ac4-8393-c866d813b8d1';
Expand All @@ -354,7 +359,7 @@ describe('Image', () => {

it('returns url for uploaded version', done => {
const version1 = {
path: '/some/image.jpg',
path: [__dirname, 'assets', 'photo.jpg'].join(pathSep),
};

const dest = '110ec58a-a0f2-4ac4-8393-c866d813b8d1';
Expand Down Expand Up @@ -594,7 +599,10 @@ describe('Integration Tests', () => {

it('uploads image to new random path', function it(done) {
this.timeout(10000);
upload.upload(`${__dirname}/assets/portrait.jpg`, {}, (e, images) => {

const file = [__dirname, 'assets', 'portrait.jpg'].join(pathSep);

upload.upload(file, {}, (e, images) => {
assert.ifError(e);

images.forEach(image => {
Expand Down Expand Up @@ -626,7 +634,7 @@ describe('Integration Tests', () => {
it('uploads image to fixed path', function it(done) {
this.timeout(10000);

const file = `${__dirname}/assets/portrait.jpg`;
const file = [__dirname, 'assets', 'portrait.jpg'].join(pathSep);
const opts = {
path: 'path/to/image',
};
Expand Down
4 changes: 3 additions & 1 deletion test/support/env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

process.env.TMP_DIR = '/tmp';
const tmpdir = require('os').tmpdir;

process.env.TMP_DIR = tmpdir();