Fix tests

This commit is contained in:
Simon MacMullen 2013-02-08 14:49:55 +00:00
parent e27251ff5d
commit 77430d339a
3 changed files with 18 additions and 18 deletions

View File

@ -1,3 +1,3 @@
DEPS:=mochiweb-wrapper webmachine-wrapper
WITH_BROKER_TEST_COMMANDS:=rabbit_mochiweb_test:test()
STANDALONE_TEST_COMMANDS:=rabbit_mochiweb_test_unit:test()
WITH_BROKER_TEST_COMMANDS:=rabbit_web_dispatch_test:test()
STANDALONE_TEST_COMMANDS:=rabbit_web_dispatch_test_unit:test()

View File

@ -14,25 +14,25 @@
%% Copyright (c) 2010-2013 VMware, Inc. All rights reserved.
%%
-module(rabbit_mochiweb_test).
-module(rabbit_web_dispatch_test).
-include_lib("eunit/include/eunit.hrl").
query_static_resource_test() ->
%% TODO this is a fairly rubbish test, but not as bad as it was
rabbit_mochiweb:register_static_context(test, [{port, 12345}],
"rabbit_mochiweb_test",
?MODULE, "priv/www", "Test"),
rabbit_web_dispatch:register_static_context(test, [{port, 12345}],
"rabbit_web_dispatch_test",
?MODULE, "priv/www", "Test"),
{ok, {_Status, _Headers, Body}} =
httpc:request("http://localhost:12345/rabbit_mochiweb_test/index.html"),
httpc:request("http://localhost:12345/rabbit_web_dispatch_test/index.html"),
?assert(string:str(Body, "RabbitMQ HTTP Server Test Page") /= 0).
add_idempotence_test() ->
F = fun(_Req) -> ok end,
L = {"/foo", "Foo"},
rabbit_mochiweb_registry:add(foo, [{port, 12345}], F, F, L),
rabbit_mochiweb_registry:add(foo, [{port, 12345}], F, F, L),
rabbit_web_dispatch_registry:add(foo, [{port, 12345}], F, F, L),
rabbit_web_dispatch_registry:add(foo, [{port, 12345}], F, F, L),
?assertEqual(
1, length([ok || {"/foo", _, _} <-
rabbit_mochiweb_registry:list_all()])),
rabbit_web_dispatch_registry:list_all()])),
passed.

View File

@ -14,27 +14,27 @@
%% Copyright (c) 2010-2013 VMware, Inc. All rights reserved.
%%
-module(rabbit_mochiweb_test_unit).
-module(rabbit_web_dispatch_test_unit).
-include_lib("eunit/include/eunit.hrl").
relativise_test() ->
?assertEqual("baz",
rabbit_mochiweb_util:relativise("/foo/bar/bash",
rabbit_web_dispatch_util:relativise("/foo/bar/bash",
"/foo/bar/baz")),
?assertEqual("../bax/baz",
rabbit_mochiweb_util:relativise("/foo/bar/bash",
rabbit_web_dispatch_util:relativise("/foo/bar/bash",
"/foo/bax/baz")),
?assertEqual("../bax/baz",
rabbit_mochiweb_util:relativise("/bar/bash",
rabbit_web_dispatch_util:relativise("/bar/bash",
"/bax/baz")),
?assertEqual("..",
rabbit_mochiweb_util:relativise("/foo/bar/bash",
rabbit_web_dispatch_util:relativise("/foo/bar/bash",
"/foo/bar")),
?assertEqual("../..",
rabbit_mochiweb_util:relativise("/foo/bar/bash",
rabbit_web_dispatch_util:relativise("/foo/bar/bash",
"/foo")),
?assertEqual("bar/baz",
rabbit_mochiweb_util:relativise("/foo/bar",
rabbit_web_dispatch_util:relativise("/foo/bar",
"/foo/bar/baz")),
?assertEqual("foo", rabbit_mochiweb_util:relativise("/", "/foo")).
?assertEqual("foo", rabbit_web_dispatch_util:relativise("/", "/foo")).