-
Notifications
You must be signed in to change notification settings - Fork 299
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
Better unit tests #100
base: master
Are you sure you want to change the base?
Better unit tests #100
Changes from 1 commit
7c9884f
fc432e9
7c7ce12
6853c65
cd964b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
require('should'); | ||
|
||
// Sync tests | ||
require('./platforms'); | ||
require('./win-releases'); | ||
|
||
// Require a backend | ||
require('./versions'); | ||
require('./download'); | ||
require('./update'); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var nuts = require('../lib'); | ||
|
||
var config = { | ||
repository: 'SamyPesse/nuts-testing', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be more handy to implement and use a The |
||
token: process.env.GITHUB_TOKEN | ||
}; | ||
|
||
var instance = nuts.Nuts(config); | ||
var app = nuts.createApp(config); | ||
|
||
module.exports = { | ||
app: app, | ||
nuts: instance | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,82 @@ | ||
var request = require('supertest'); | ||
var expect = require('expect'); | ||
var app = require('./app'); | ||
|
||
var app = require('./testing').app; | ||
|
||
describe('Update', function() { | ||
var agent = request.agent(app); | ||
|
||
describe('Squirrel.Mac (OS X)', function() { | ||
|
||
it('should return a 204 if using latest version', function(done) { | ||
agent | ||
.get('/update/osx/1.0.0') | ||
.expect(204, done); | ||
describe('/update/osx/', function() { | ||
it('should return a 204 if using latest version', function(done) { | ||
agent | ||
.get('/update/osx/1.0.0') | ||
.expect(204, done); | ||
}); | ||
|
||
it('should return a 200 with json if using old stable version', function(done) { | ||
agent | ||
.get('/update/osx/0.9.0') | ||
.expect('Content-Type', /json/) | ||
.expect(function(res) { | ||
expect(res.body.name).toBe('1.0.0'); | ||
expect(res.body.url).toExist(); | ||
expect(res.body.pub_date).toExist(); | ||
}) | ||
.expect(200, done); | ||
}); | ||
|
||
it('should return a 200 with json if using old beta version (1)', function(done) { | ||
agent | ||
.get('/update/osx/0.9.1-beta') | ||
.expect('Content-Type', /json/) | ||
.expect(function(res) { | ||
expect(res.body.name).toBe('1.0.0'); | ||
}) | ||
.expect(200, done); | ||
}); | ||
|
||
it('should return a 200 with json if using old beta version (2)', function(done) { | ||
agent | ||
.get('/update/osx/0.9.1-beta.1') | ||
.expect('Content-Type', /json/) | ||
.expect(function(res) { | ||
expect(res.body.name).toBe('1.0.0'); | ||
}) | ||
.expect(200, done); | ||
}); | ||
}); | ||
|
||
it('should return a 200 with json if using old version', function(done) { | ||
agent | ||
.get('/update/osx/0.9.0') | ||
.expect('Content-Type', /json/) | ||
.expect(function(res) { | ||
expect(res.body.name).toBe('1.0.0'); | ||
expect(res.body.url).toExist(); | ||
expect(res.body.pub_date).toExist(); | ||
}) | ||
.expect(200, done); | ||
describe('/update/channel/beta/osx', function() { | ||
it('should update from 0.9.1-beta to 1.0.1-beta.0', function(done) { | ||
agent | ||
.get('/update/channel/beta/osx/0.9.1-beta') | ||
.expect('Content-Type', /json/) | ||
.expect(function(res) { | ||
expect(res.body.name).toBe('1.0.1-beta.0'); | ||
}) | ||
.expect(200, done); | ||
}); | ||
|
||
it('should not update from 1.0.1-beta.0', function(done) { | ||
agent | ||
.get('/update/channel/beta/osx/1.0.1-beta.0') | ||
.expect(204, done); | ||
}); | ||
}); | ||
|
||
describe('/update/channel/alpha/osx', function() { | ||
it('should update from 0.9.1-beta to 1.1.0-alpha.0', function(done) { | ||
agent | ||
.get('/update/channel/alpha/osx/0.9.1-beta') | ||
.expect('Content-Type', /json/) | ||
.expect(function(res) { | ||
expect(res.body.name).toBe('1.1.0-alpha.0'); | ||
}) | ||
.expect(200, done); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var expect = require('expect'); | ||
var versions = require('./testing').nuts.versions; | ||
|
||
describe('Versions', function() { | ||
|
||
describe('.list', function() { | ||
it('should list all versions', function() { | ||
return versions.list() | ||
.then(function(out) { | ||
expect(out.length).toEqual(6); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('.filter', function() { | ||
|
||
it('should filter correctly by tag name', function() { | ||
return versions.filter({ tag: '>=0.9.0' }) | ||
.then(function(out) { | ||
expect(out.length).toEqual(2); | ||
expect(out[0].tag).toEqual('1.0.0'); | ||
expect(out[1].tag).toEqual('0.9.0'); | ||
}); | ||
}); | ||
|
||
it('should filter correctly by tag name (stripChannel)', function() { | ||
return versions.filter({ | ||
tag: '>=0.9.0', | ||
channel: '*', | ||
stripChannel: true | ||
}) | ||
.then(function(out) { | ||
expect(out.length).toEqual(6); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why
stripChannel
should be striped.Imagine we have a version⚠️
0.1.53-beta
in releases (0.1.53
is not in release yet):With
stripChannel=true
:/update/channel/beta/darwin_x64/0.1.53
leads to0.1.53-beta
=> will install a lower versionWith
stripChannel=false
:/update/channel/beta/darwin_x64/0.1.53
leads to 204There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to remove the
stripChannel
but I ran into other problem: I was not able to update an user on a stable version to a beta version, because of howsemver.satisfies
handle the prerelease tag. Such a nightmare..