Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

test: Make tap tests not rely on gists

Too slow and unreliable.  Still need to work out how to make this work
for the other non-tap tests.  Maybe those should all just go away.
  • Loading branch information...
commit 3d1ac903c657c01e28e295001a5f34a742c801e1 1 parent b2eacd4
@isaacs isaacs authored
View
66 test/tap/peer-deps-invalid.js
@@ -2,23 +2,75 @@ var fs = require("fs")
var test = require("tap").test
var rimraf = require("rimraf")
var npm = require("../../")
+var http = require("http")
+
+var okFile = new Buffer(
+'/**package\n' +
+' * { "name": "npm-test-peer-deps-file"\n' +
+' * , "main": "index.js"\n' +
+' * , "version": "1.2.3"\n' +
+' * , "description":"No package.json in sight!"\n' +
+' * , "peerDependencies": { "dict": "1.1.0" }\n' +
+' * , "dependencies": { "opener": "1.3.0" }\n' +
+' * }\n' +
+' **/\n' +
+'\n' +
+'module.exports = "I\'m just a lonely index, naked as the day I was born."\n'
+)
+
+var failFile = new Buffer(
+'/**package\n' +
+' * { "name": "npm-test-peer-deps-file-invalid"\n' +
+' * , "main": "index.js"\n' +
+' * , "version": "1.2.3"\n' +
+' * , "description":"This one should conflict with the other one"\n' +
+' * , "peerDependencies": { "dict": "1.0.0" }\n' +
+' * }\n' +
+' **/\n' +
+'\n' +
+'module.exports = "I\'m just a lonely index, naked as the day I was born."\n'
+)
+
+var server
+test("setup", function(t) {
+ server = http.createServer(function (req, res) {
+ res.setHeader('content-type', 'application/javascript')
+ switch (req.url) {
+ case "/ok.js":
+ return res.end(okFile)
+ default:
+ return res.end(failFile)
+ }
+ })
+ server.listen(1337, function() {
+ t.pass("listening")
+ t.end()
+ })
+})
-test("installing dependencies that having conflicting peerDependencies", function (t) {
- t.plan(1)
+
+test("installing dependencies that having conflicting peerDependencies", function (t) {
rimraf.sync(__dirname + "/peer-deps-invalid/node_modules")
process.chdir(__dirname + "/peer-deps-invalid")
npm.load(function () {
+ console.error('back from load')
npm.commands.install([], function (err) {
+ console.error('back from install')
if (!err) {
t.fail("No error!")
- process.exit(1)
- return
+ } else {
+ t.equal(err.code, "EPEERINVALID")
}
-
- t.equal(err.code, "EPEERINVALID")
- process.exit(0)
+ t.end()
})
})
})
+
+test("shutdown", function(t) {
+ server.close(function() {
+ t.pass("closed")
+ t.end()
+ })
+})
View
4 test/tap/peer-deps-invalid/package.json
@@ -3,7 +3,7 @@
"name": "peer-deps-invalid",
"version": "0.0.0",
"dependencies": {
- "npm-test-peer-deps-file": "https://raw.github.com/gist/3971128/3f6aa37b4fa1186c2f47da9b77dcc4ec496e3483/index.js",
- "npm-test-peer-deps-file-invalid": "https://gist.github.com/raw/4303335/861f8d3213061826ab31591840c3cb0ac737f4fc/index.js"
+ "npm-test-peer-deps-file": "http://localhost:1337/ok.js",
+ "npm-test-peer-deps-file-invalid": "http://localhost:1337/invalid.js"
}
}
View
47 test/tap/peer-deps-without-package-json.js
@@ -3,7 +3,33 @@ var test = require("tap").test
var rimraf = require("rimraf")
var npm = require("../../")
-var peerDepsTestUrl = "https://gist.github.com/raw/3971128/3f6aa37b4fa1186c2f47da9b77dcc4ec496e3483/index.js"
+var http = require("http")
+
+
+var js = new Buffer(
+'/**package\n' +
+' * { "name": "npm-test-peer-deps-file"\n' +
+' * , "main": "index.js"\n' +
+' * , "version": "1.2.3"\n' +
+' * , "description":"No package.json in sight!"\n' +
+' * , "peerDependencies": { "dict": "1.1.0" }\n' +
+' * , "dependencies": { "opener": "1.3.0" }\n' +
+' * }\n' +
+' **/\n' +
+'\n' +
+'module.exports = "I\'m just a lonely index, naked as the day I was born."\n')
+
+var server
+test("setup", function(t) {
+ server = http.createServer(function (q, s) {
+ s.setHeader('content-type', 'application/javascript')
+ s.end(js)
+ })
+ server.listen(1337, function() {
+ t.pass('listening')
+ t.end()
+ })
+})
test("installing a peerDependencies-using package without a package.json present (GH-3049)", function (t) {
@@ -12,18 +38,21 @@ test("installing a peerDependencies-using package without a package.json present
process.chdir(__dirname + "/peer-deps-without-package-json")
npm.load(function () {
- npm.install(peerDepsTestUrl, function (err) {
+ npm.install('http://localhost:1337/', function (err) {
if (err) {
t.fail(err)
- t.end()
- process.exit(1)
- return
+ } else {
+ t.ok(fs.existsSync(__dirname + "/peer-deps-without-package-json/node_modules/npm-test-peer-deps-file"))
+ t.ok(fs.existsSync(__dirname + "/peer-deps-without-package-json/node_modules/dict"))
}
-
- t.ok(fs.existsSync(__dirname + "/peer-deps-without-package-json/node_modules/npm-test-peer-deps-file"))
- t.ok(fs.existsSync(__dirname + "/peer-deps-without-package-json/node_modules/dict"))
t.end()
- process.exit(0)
})
})
})
+
+test("cleanup", function (t) {
+ server.close(function() {
+ t.pass("closed")
+ t.end()
+ })
+})
Please sign in to comment.
Something went wrong with that request. Please try again.