Skip to content

Commit

Permalink
REST: Adding an unittest for issue vibe-d#1125
Browse files Browse the repository at this point in the history
  • Loading branch information
Geod24 committed Jun 10, 2015
1 parent 79235aa commit ef545dc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/vibe.web.rest.1125/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1125
7 changes: 7 additions & 0 deletions tests/vibe.web.rest.1125/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "1125",
"dependencies": {
"vibe-d": { "path": "../../../" }
},
"versions": ["VibeDefaultMain"]
}
34 changes: 34 additions & 0 deletions tests/vibe.web.rest.1125/source/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import vibe.d;
import std.datetime;

shared static this()
{
auto settings = new HTTPServerSettings;
// 10k + issue number -> Avoid bind errors
settings.port = 11125;
settings.bindAddresses = ["::1", "127.0.0.1"];
auto router = new URLRouter;
router.registerRestInterface(new Llama);
listenHTTP(settings, router);

// Client
setTimer(1.seconds, {
scope(exit) exitEventLoop(true);

auto api = new RestInterfaceClient!ILlama("http://127.0.0.1:11125/");
auto r = api.updateLlama("llama");
assert(r == "llama", "[vibe.web.rest.1125.Client] Expected llama, got: " ~ r);
});
}

interface ILlama {
@bodyParam("llama", "llama")
string updateLlama(string llama = null);
}

class Llama : ILlama {
string updateLlama(string llama) {
assert(llama == "llama", "[vibe.web.rest.1125.Server] Expected llama, got: " ~ llama);
return llama;
}
}

0 comments on commit ef545dc

Please sign in to comment.