Closed hpurmann closed 10 years ago
It starts a server during testing
https://github.com/twolfson/grunt-curl/blob/1.4.0/test/curl_test_content.js#L28-L39
Let's get the obvious parts out of the way:
npm install
?npm
and node
are you on?Ah sorry, I didn't saw this. But the problem remains: It doesn't start a server for me.
Hmmm, have you ever removed localhost
from your /etc/hosts
? It is usually a default on most machines.
# Linux/OSX
cat /etc/hosts
# Windows: Open in notepad.exe
C:\WIndows\system32\drivers\etc\hosts
I'm getting
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
Seems ok, doesn't it?
Yea, it does =_=
Let's perform a sanity check. serve
is a CLI tool that hosts a directory on a local web server. Please install serve
globally
npm install -g serve
https://www.npmjs.org/package/serve
Then, run it locally and try accessing these various URLs:
serve .
http://localhost:3000/ http://127.0.0.1:3000/ http://0.0.0.0:3000/
Sorry, that I answer so late now. serve
works well.
All of the 3 URLs worked?
Yes
I am afraid I am out of ideas o_o
The next step would be to strip away code pieces until we are left with nothing but the failing test. Can you move your outline.yml
to:
- 'grunt curl':
- 'using POST':
- 'is successful'
You might see some warnings about unused keys but ignore them.
Where is this outline file? Sorry for that probably dumb question but I couldn't find it.
No worries, this uses a non-canonical testing framework, doubleshot
. I was going through an experimentation phase.
https://github.com/twolfson/doubleshot
The outline can be found here in test/curl_test_outline.yml
:
https://github.com/twolfson/grunt-curl/blob/1.4.0/test/curl_test_outline.yml
Ok I deleted everything in curl_test_outline.yml
and added your lines but nothing changed. Does the content of the file actually affects the outcome of the test?
No, it was just to run the test in isolation. If you were to adjust the outline to everything but the failing test, it should pass.
# Clean up the test directory
- 'A clean test directory':
- 'is clean'
# curl tests
- 'grunt curl':
- 'downloading a js (utf16) file':
- 'is successful'
- 'downloading a zip (binary) file':
- 'is successful'
- 'downloading a file from an invalid domain':
- 'throws an error'
- 'does not create the file'
- 'downloading a nonexistant file':
- 'throws an error'
- 'does not create the file'
- 'downloading a POST file':
- 'is successful'
# curl-dir tests
- 'grunt curl-dir':
- 'downloading multiple files':
- 'is successful'
- 'downloading brace expanded files':
- 'is successful'
- 'using a custom router':
- 'is successful'
I am realizing that no other tests use a local express
server and wonder if it has anything to do with that.
Going to rewrite test suite as I am trying to move away from doubleshot
. Then, going to add a test for GET
against a local server.
This probably won't change anything but it might allow us to debug easier.
Alright, transitioned onto mocha
in 1.5.0
. Adding local GET
test now.
In 1.5.1
I have added a local GET
test. Please pull that down and try to run them.
I pulled down your commits and it says that no clean targets were found. As I deleted the invocation of clean it gave me the same error again:
Running "curl:js" (curl) task
File "actual/file.js" created.
Running "curl:zip" (curl) task
File "actual/file.zip" created.
Running "curl:get" (curl) task
Warning: connect ECONNREFUSED Use --force to continue.
Aborted due to warnings.
Alright, I think I know the issue. You are attempting to run the tests via grunt
or some variation but that is not how we test in this repo. We test via npm test
. If you follow the instructions below, the tests should work:
# Clone repo
git clone https://github.com/twolfson/grunt-curl
cd grunt-curl/
# Install dependencies
npm install
# Run tests
npm test
The output should look like:
$ npm test
> grunt-curl@1.5.1 test /Users/todd/github/grunt-curl
> rm -r test/actual 2> /dev/null; mocha
․․․․․․․․․․․․․․․
15 passing (8s)
Oh ok! I always thought of testing with the grunt
command in the test
folder. Sorry that I wasted your time, npm test
works like a charm!
I just forked this repo and tried to run the Gruntfile in the test folder. I got this:
Looking at
'curl-dir':post
in thegrunt.js
file I saw that you assume a file athttp://localhost:4000/post.txt
Why? I think all test tasks should pass after I just forked it.