Permalink
Browse files

Gemcutter endpoint API test for Gemcutter DEPENDENCY LIMIT

  • Loading branch information...
1 parent 48516f7 commit 64133bbb5a27b17430fa3e06291bc94e657ea356 @hone hone committed Nov 9, 2010
Showing with 43 additions and 1 deletion.
  1. +27 −0 spec/install/gems/dependency_api_spec.rb
  2. +16 −1 spec/support/artifice/endpoint.rb
@@ -39,4 +39,31 @@
bundle :install, :fakeweb => "windows"
should_be_installed "rcov 1.0.0"
end
+
+ it "falls back when hitting the Gemcutter Dependency Limit" do
+ gemfile <<-G
+ source "http://localgemserver.test"
+ gem "activesupport"
+ gem "actionpack"
+ gem "actionmailer"
+ gem "activeresource"
+ gem "thin"
+ gem "rack"
+ gem "rails"
+ G
+ bundle :install, :artifice => "endpoint"
+
+ [
+ ["activesupport", "2.3.2"],
+ ["actionpack", "2.3.2"],
+ ["actionmailer", "2.3.2"],
+ ["activeresource", "2.3.2"],
+ ["activesupport", "2.3.2"],
+ ["thin", "1.0.0"],
+ ["rack", "1.0.0"],
+ ["rails", "2.3.2"]
+ ].each do |gem, version|
+ should_be_installed "#{gem} #{version}"
+ end
+ end
end
@@ -12,6 +12,8 @@
require 'sinatra/base'
class Endpoint < Sinatra::Base
+ DEPENDENCY_LIMIT = 55
+
helpers do
def dependencies_for(gem_names)
require 'rubygems'
@@ -30,6 +32,14 @@ def dependencies_for(gem_names)
end
end
+ get "/specs.4.8.gz" do
+ File.read("#{gem_repo1}/specs.4.8.gz")
+ end
+
+ get "/prerelease_specs.4.8.gz" do
+ File.read("#{gem_repo1}/prerelease_specs.4.8.gz")
+ end
+
get "/quick/Marshal.4.8/:id" do
File.read("#{gem_repo1}/quick/Marshal.4.8/#{params[:id]}")
end
@@ -39,7 +49,12 @@ def dependencies_for(gem_names)
end
get "/api/v1/dependencies" do
- Marshal.dump(dependencies_for(params[:gems]))
+ if params[:gems].size <= DEPENDENCY_LIMIT
+ Marshal.dump(dependencies_for(params[:gems]))
+ else
+ status 413
+ "Too many gems to resolve, please request less than #{DEPENDENCY_LIMIT} gems"
+ end
end
end

0 comments on commit 64133bb

Please sign in to comment.