Skip to content

Commit

Permalink
Test delete via post
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsamson committed Feb 19, 2016
1 parent 29d37ca commit e316e92
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/controllers/venue_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,25 @@ defmodule Stackfooter.VenueControllerTest do
assert resp["error"] == "Not authorized to delete that order. You have to own account RJSAMSON."
end

test "cancels an order with a post request" do
{:ok, venue} = VenueRegistry.lookup(Stackfooter.VenueRegistry, "OBEX")
Venue.reset(venue)
Venue.place_order(venue, %{direction: "sell", symbol: "NYC", qty: 5, price: 0, account: "admin", orderType: "market"})

expected_order = %{"account" => "ADMIN", "direction" => "sell", "fills" => [], "id" => 0,
"ok" => true, "open" => false, "orderType" => "market", "originalQty" => 5,
"price" => 0, "qty" => 0, "symbol" => "NYC", "totalFilled" => 0,
"venue" => "OBEX"}

conn = put_req_header(conn(), "x-starfighter-authorization", @apikey)
|> post("ob/api/venues/obex/stocks/nyc/orders/0/cancel")
resp = json_response(conn, 200)

assert resp
assert resp["ok"]
assert strip_timestamps(resp) == expected_order
end

test "returns the order when cancelling a closed order" do
{:ok, venue} = VenueRegistry.lookup(Stackfooter.VenueRegistry, "OBEX")
Venue.reset(venue)
Expand Down

0 comments on commit e316e92

Please sign in to comment.