Skip to content

Commit

Permalink
Re-order tests to improve readability.
Browse files Browse the repository at this point in the history
Change-Id: I35aa3253c97a0b5e8464f0782280652236a353e2
  • Loading branch information
Kowshik Prakasam committed Oct 4, 2012
1 parent 0c5a2b6 commit ef3f57e
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions spec/api/files_spec.rb
Expand Up @@ -43,6 +43,36 @@ module VCAP::CloudController
last_response.status.should == 400
end

it "should return the staging task log if it exists" do
redis_client = mock("redis")

task_log = StagingTaskLog.new(@app.guid, "task log", redis_client)
Redis.stub(:new).and_return(redis_client)
StagingTaskLog.should_receive(:fetch).with(@app.guid, redis_client)
.and_return(task_log)

get("/v2/apps/#{@app.guid}/instances/1/files/logs/staging.log",
{},
headers_for(@developer))

last_response.status.should == 200
last_response.body.should == "task log"
end

it "should return 404 if staging task log is absent" do
redis_client = mock("redis")

Redis.stub(:new).and_return(redis_client)
StagingTaskLog.should_receive(:fetch).with(@app.guid, redis_client)
.and_return(nil)

get("/v2/apps/#{@app.guid}/instances/1/files/logs/staging.log",
{},
headers_for(@developer))

last_response.status.should == 404
end

context "dea returns file uri v1" do
it "should return 400 when accessing of the file URL fails", :use_nginx => false do
instance_id = 5
Expand Down Expand Up @@ -259,36 +289,6 @@ module VCAP::CloudController
last_response.headers["Range"] == "bytes=100-200"
end
end

it "should return the staging task log if it exists" do
redis_client = mock("redis")

task_log = StagingTaskLog.new(@app.guid, "task log", redis_client)
Redis.stub(:new).and_return(redis_client)
StagingTaskLog.should_receive(:fetch).with(@app.guid, redis_client)
.and_return(task_log)

get("/v2/apps/#{@app.guid}/instances/1/files/logs/staging.log",
{},
headers_for(@developer))

last_response.status.should == 200
last_response.body.should == "task log"
end

it "should return 404 if staging task log is absent" do
redis_client = mock("redis")

Redis.stub(:new).and_return(redis_client)
StagingTaskLog.should_receive(:fetch).with(@app.guid, redis_client)
.and_return(nil)

get("/v2/apps/#{@app.guid}/instances/1/files/logs/staging.log",
{},
headers_for(@developer))

last_response.status.should == 404
end
end

context "as a user" do
Expand Down

0 comments on commit ef3f57e

Please sign in to comment.