Purge all buckets before every test

This commit is contained in:
galfert 2012-09-26 11:02:52 +02:00
parent ebe499211a
commit 8af6016d99
2 changed files with 9 additions and 106 deletions

View File

@ -4,20 +4,8 @@ describe "Permissions" do
include Rack::Test::Methods include Rack::Test::Methods
include RemoteStorage::Riak include RemoteStorage::Riak
def app before do
LiquorCabinet purge_all_buckets
end
def storage_client
@storage_client ||= ::Riak::Client.new(settings.riak_config)
end
def data_bucket
@data_bucket ||= storage_client.bucket("user_data")
end
def auth_bucket
@auth_bucket ||= storage_client.bucket("authorizations")
end end
describe "public data" do describe "public data" do
@ -34,11 +22,6 @@ describe "Permissions" do
object.store object.store
end end
after do
data_bucket.delete("jimmy:public:foo")
data_bucket.delete("jimmy:public/documents:foo")
end
it "returns the value on all get requests" do it "returns the value on all get requests" do
get "/jimmy/public/foo" get "/jimmy/public/foo"
@ -82,13 +65,6 @@ describe "Permissions" do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
end end
after do
data_bucket.delete("jimmy:documents:foo")
data_bucket.delete("jimmy:documents/very/interesting:text")
data_bucket.delete("jimmy:confidential:bar")
auth_bucket.delete("jimmy:123")
end
describe "when authorized" do describe "when authorized" do
it "returns the value for a key in a top-level directory" do it "returns the value for a key in a top-level directory" do
get "/jimmy/documents/foo" get "/jimmy/documents/foo"
@ -123,15 +99,7 @@ describe "Permissions" do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
end end
after do
auth_bucket.delete("jimmy:123")
end
describe "to a top-level directory" do describe "to a top-level directory" do
after do
data_bucket.delete("jimmy:contacts:1")
end
it "saves the value when there are write permissions" do it "saves the value when there are write permissions" do
put "/jimmy/contacts/1", "John Doe" put "/jimmy/contacts/1", "John Doe"
@ -147,11 +115,6 @@ describe "Permissions" do
end end
describe "to a sub-directory" do describe "to a sub-directory" do
after do
data_bucket.delete("jimmy:tasks/home:1")
data_bucket.delete("jimmy:contacts/family:1")
end
it "saves the value when there are direct write permissions" do it "saves the value when there are direct write permissions" do
put "/jimmy/tasks/home/1", "take out the trash" put "/jimmy/tasks/home/1", "take out the trash"
@ -183,10 +146,6 @@ describe "Permissions" do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
end end
after do
auth_bucket.delete("jimmy:123")
end
describe "when authorized" do describe "when authorized" do
before do before do
object = data_bucket.new("jimmy:tasks:1") object = data_bucket.new("jimmy:tasks:1")
@ -232,11 +191,6 @@ describe "Permissions" do
object.store object.store
end end
after do
data_bucket.delete("jimmy:documents:private")
data_bucket.delete("jimmy:documents/business:foo")
end
it "returns a 403 for a key in a top-level directory" do it "returns a 403 for a key in a top-level directory" do
delete "/jimmy/documents/private" delete "/jimmy/documents/private"
@ -260,10 +214,6 @@ describe "Permissions" do
object.store object.store
end end
after do
data_bucket.delete("jimmy:documents/very/interesting:text")
end
describe "write all" do describe "write all" do
before do before do
auth = auth_bucket.new("jimmy:123") auth = auth_bucket.new("jimmy:123")
@ -273,11 +223,6 @@ describe "Permissions" do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
end end
after do
auth_bucket.delete("jimmy:123")
data_bucket.delete("jimmy:contacts:1")
end
it "allows GET requests" do it "allows GET requests" do
get "/jimmy/documents/very/interesting/text" get "/jimmy/documents/very/interesting/text"
@ -311,10 +256,6 @@ describe "Permissions" do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
end end
after do
auth_bucket.delete("jimmy:123")
end
it "allows GET requests" do it "allows GET requests" do
get "/jimmy/documents/very/interesting/text" get "/jimmy/documents/very/interesting/text"

View File

@ -4,20 +4,8 @@ describe "App with Riak backend" do
include Rack::Test::Methods include Rack::Test::Methods
include RemoteStorage::Riak include RemoteStorage::Riak
def app before do
LiquorCabinet purge_all_buckets
end
def storage_client
@storage_client ||= ::Riak::Client.new(settings.riak_config)
end
def data_bucket
@data_bucket ||= storage_client.bucket("user_data")
end
def auth_bucket
@auth_bucket ||= storage_client.bucket("authorizations")
end end
describe "GET public data" do describe "GET public data" do
@ -28,10 +16,6 @@ describe "App with Riak backend" do
object.store object.store
end end
after do
data_bucket.delete("jimmy:public:foo")
end
it "returns the value on all get requests" do it "returns the value on all get requests" do
get "/jimmy/public/foo" get "/jimmy/public/foo"
@ -48,10 +32,6 @@ describe "App with Riak backend" do
object.store object.store
end end
after do
data_bucket.delete("jimmy:public:magic")
end
it "returns the value with the correct content type" do it "returns the value with the correct content type" do
get "/jimmy/public/magic" get "/jimmy/public/magic"
@ -73,11 +53,6 @@ describe "App with Riak backend" do
auth.store auth.store
end end
after do
data_bucket.delete("jimmy:documents:foo")
auth_bucket.delete("jimmy:123")
end
describe "GET" do describe "GET" do
it "returns the value" do it "returns the value" do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
@ -107,10 +82,6 @@ describe "App with Riak backend" do
put "/jimmy/documents/bar", "another text" put "/jimmy/documents/bar", "another text"
end end
after do
data_bucket.delete("jimmy:documents:bar")
end
it "saves the value" do it "saves the value" do
last_response.status.must_equal 200 last_response.status.must_equal 200
data_bucket.get("jimmy:documents:bar").data.must_equal "another text" data_bucket.get("jimmy:documents:bar").data.must_equal "another text"
@ -121,8 +92,11 @@ describe "App with Riak backend" do
end end
it "indexes the data set" do it "indexes the data set" do
data_bucket.get("jimmy:documents:bar").indexes["user_id_bin"].must_be_kind_of Set indexes = data_bucket.get("jimmy:documents:bar").indexes
data_bucket.get("jimmy:documents:bar").indexes["user_id_bin"].must_include "jimmy" indexes["user_id_bin"].must_be_kind_of Set
indexes["user_id_bin"].must_include "jimmy"
indexes["directory_bin"].must_include "documents"
end end
end end
@ -132,10 +106,6 @@ describe "App with Riak backend" do
put "/jimmy/documents/jason", '{"foo": "bar", "unhosted": 1}' put "/jimmy/documents/jason", '{"foo": "bar", "unhosted": 1}'
end end
after do
data_bucket.delete("jimmy:documents:jason")
end
it "saves the value (as JSON)" do it "saves the value (as JSON)" do
last_response.status.must_equal 200 last_response.status.must_equal 200
data_bucket.get("jimmy:documents:jason").data.must_be_kind_of Hash data_bucket.get("jimmy:documents:jason").data.must_be_kind_of Hash
@ -161,10 +131,6 @@ describe "App with Riak backend" do
put "/jimmy/documents/magic", "pure magic" put "/jimmy/documents/magic", "pure magic"
end end
after do
data_bucket.delete("jimmy:documents:magic")
end
it "saves the value" do it "saves the value" do
last_response.status.must_equal 200 last_response.status.must_equal 200
data_bucket.get("jimmy:documents:magic").raw_data.must_equal "pure magic" data_bucket.get("jimmy:documents:magic").raw_data.must_equal "pure magic"
@ -206,10 +172,6 @@ describe "App with Riak backend" do
header "Authorization", "Bearer 321" header "Authorization", "Bearer 321"
end end
after do
auth_bucket.delete("jimmy:123")
end
describe "GET" do describe "GET" do
it "returns a 403" do it "returns a 403" do
get "/jimmy/documents/foo" get "/jimmy/documents/foo"