gentoo / GenTwoo-backend

[ORIGIN] (no description)
9 stars 6 forks source link

Implement register rpc call #3 #12

Closed naota closed 10 years ago

naota commented 10 years ago

This pull request implement application's base layout and register rpc call.

These three commits are important:

Some test results:

$ curl  localhost:3000/ --header "accept: application/json"
{"message":"Not Found"}%
$ curl -d '' localhost:3000/ --header "accept: application/json"
{"message":"Not Found"}%
$ curl -d '' localhost:3000/v0/register --header "accept: application/json"
{"message":"Invalid Arguments","errors":["ParseError {errorContexts = [\"demandInput\"], errorMessage = \"not enough bytes\", errorPosition = 1:1}"]}%
$ curl -d '{"foo": "bar"}' localhost:3000/v0/register --header "accept: application/json"
{"message":"Invalid Arguments","errors":["The key \"uuid\" was not found"]}%
$ curl -d '{"uuid": "foo"}' localhost:3000/v0/register --header "accept: application/json"
{"message":"Permission Denied. Specified UUID already exist"}%
$ curl -d '{"uuid": "foobar"}' localhost:3000/v0/register --header "accept: application/json"
{"status":"registered"}%
jan-matejka commented 10 years ago

And please document the official way to run tests, probably in README.rst

jan-matejka commented 10 years ago

It would be probably good to make sure the migrations are run automatically on startup only in Development environment in the future.

jan-matejka commented 10 years ago

I'm getting some warnings about redundant imports when running tests. Otherwise pretty cool, works as advertised and tests are passing.

jan-matejka commented 10 years ago

Most of the issues I raised are either invalid or can be fixed later besides the needless static/html files. Please clean those up and I will merge.

jan-matejka commented 10 years ago

please rebase -i to squash the appropriate commits so the additions/deletions don't get into history.

jan-matejka commented 10 years ago
yac@rainbowdash % .cabal-sandbox/bin/yesod test
Resolving dependencies...
Configuring GenTwoo-backend-0.1.0...
Building GenTwoo-backend-0.1.0...
Preprocessing library GenTwoo-backend-0.1.0...
In-place registering GenTwoo-backend-0.1.0...
Preprocessing test suite 'test' for GenTwoo-backend-0.1.0...
Linking dist/build/test/test ...
Building GenTwoo-backend-0.1.0...
Preprocessing library GenTwoo-backend-0.1.0...
In-place registering GenTwoo-backend-0.1.0...
Preprocessing test suite 'test' for GenTwoo-backend-0.1.0...
Linking dist/build/test/test ...
Running 1 test suites...
Test suite test: RUNNING...
Test suite test: PASS
Test suite logged to: dist/test/GenTwoo-backend-0.1.0-test.log
1 of 1 test suites (1 of 1 test cases) passed.

yac@rainbowdash % curl -d '{"uuid": "9cc7f702-bd25-4d1b-9da1-af8d70549500"}' localhost:3000/v0/register
{"status":"registered"}%                                                                                                                                                  --------------------------------------------------------------------------------
~
yac@rainbowdash % curl -d '{"uuid": "9cc7f702-bd25-4d1b-9da1-af8d70549500"}' localhost:3000/v0/register
<!DOCTYPE html>
<html><head><title>Permission Denied</title></head><body><h1>Permission denied</h1>
<p>Specified UUID already exist</p>
</body></html>%                                                                                                                                                           --------------------------------------------------------------------------------
~
yac@rainbowdash % curl -d '{"uuid2": "9cc7f702-bd25-4d1b-9da1-af8d70549500"}' localhost:3000/v0/register
<!DOCTYPE html>
<html><head><title>Invalid Arguments</title></head><body><h1>Invalid Arguments</h1>
<ul><li>The key &quot;uuid&quot; was not found</li>
</ul>
</body></html>%                                                                                                                                                           --------------------------------------------------------------------------------
~
yac@rainbowdash % curl -d '' localhost:3000/v0/register
<!DOCTYPE html>
<html><head><title>Invalid Arguments</title></head><body><h1>Invalid Arguments</h1>
<ul><li>ParseError {errorContexts = [&quot;demandInput&quot;], errorMessage = &quot;not enough bytes&quot;, errorPosition = 1:1}</li>
</ul>
</body></html>%