Skip to content

Commit

Permalink
Merge pull request #541 from Geod24/fix-unittests
Browse files Browse the repository at this point in the history
The tests where not working.
  • Loading branch information
s-ludwig committed Feb 24, 2014
2 parents e145c18 + ef5f60e commit 9013aaa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
/docs/styles

.dub

# Unittest binaries
vibe-d
tests/*/tests
4 changes: 2 additions & 2 deletions tests/args/test.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -e
die() { echo "$@" 1>&2 ; exit 1; }

if [ "${OS}" == "win32" -o "${OS}" == "Windows_NT" ]; then
VIBE='cmd /C vibe'
VIBE='cmd /C tests'
else
VIBE=vibe
VIBE=./tests
fi

( $VIBE | grep -q '^argtest=$' ) || die "Fail (no argument)"
Expand Down
3 changes: 2 additions & 1 deletion tests/mongodb/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ void runTest()
auto converted = zip(data1, data2).map!( a => a[0].key1.get!string() ~ a[1].key1.get!string() )();
assert(!converted.empty);
assert(converted.front == "value1value2");
exitEventLoop(true);
}

int main()
{
setLogLevel(LogLevel.Debug);
setLogLevel(LogLevel.debug_);
runTask(toDelegate(&runTest));
return runEventLoop();
}
15 changes: 8 additions & 7 deletions tests/restclient/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import vibe.vibe;

interface ITestAPI
{
@method(HttpMethod.POST) @path("other/path")
@method(HTTPMethod.POST) @path("other/path")
string info();
string getInfo();
@path("getCheck/:param/:param2") @method(HttpMethod.GET)
@path("getCheck/:param/:param2") @method(HTTPMethod.GET)
string customParameters(string _param, string _param2);
@path("getCheck2/:param/:param2") @method(HttpMethod.GET)
@path("getCheck2/:param/:param2") @method(HTTPMethod.GET)
int customParameters2(int _param, bool _param2);
}

Expand All @@ -23,25 +23,26 @@ class TestAPI : ITestAPI

void runTest()
{
auto router = new UrlRouter;
auto router = new URLRouter;
registerRestInterface!ITestAPI(router, new TestAPI, "/root/");

auto settings = new HttpServerSettings;
auto settings = new HTTPServerSettings;
settings.disableDistHost = true;
settings.port = 8000;
listenHttp(settings, router);
listenHTTP(settings, router);

auto api = new RestInterfaceClient!ITestAPI("http://127.0.0.1:8000/root/");
assert(api.getInfo() == "description");
assert(api.info() == "description2");
assert(api.customParameters("one", "two") == "onetwo");
assert(api.customParameters2(10, false) == -10);
assert(api.customParameters2(10, true) == 10);
exitEventLoop(true);
}

int main()
{
setLogLevel(LogLevel.Debug);
setLogLevel(LogLevel.debug_);
runTask(toDelegate(&runTest));
return runEventLoop();
}

0 comments on commit 9013aaa

Please sign in to comment.