Skip to content

Commit

Permalink
feat: add error testing endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Mar 8, 2018
1 parent f7e0278 commit 4e01407
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/pact_broker/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module PactBroker
add ['matrix'], Api::Resources::Matrix, {resource_name: "matrix"}

add ['dashboard'], Api::Resources::Dashboard, {resource_name: "dashboard"}
add ['test','error'], Api::Resources::ErrorTest, {resource_name: "error_test"}
add [], Api::Resources::Index, {resource_name: "index"}
end
end
Expand Down
36 changes: 36 additions & 0 deletions lib/pact_broker/api/resources/error_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'pact_broker/api/resources/base_resource'
require 'pact_broker/error'

module PactBroker
module Api
module Resources

class ErrorTest < BaseResource

def content_types_provided
[
["application/hal+json", :to_json]
]
end

def content_types_accepted
[
["application/hal+json", :from_json]
]
end

def allowed_methods
["GET", "POST"]
end

def to_json
raise PactBroker::Error.new("Don't panic. This is a test API error.")
end

def from_json
raise PactBroker::Error.new("Don't panic. This is a test API error.")
end
end
end
end
end
7 changes: 6 additions & 1 deletion lib/pact_broker/ui/app.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'pact_broker/ui/controllers/index'
require 'pact_broker/ui/controllers/groups'
require 'pact_broker/ui/controllers/matrix'
require 'pact_broker/ui/controllers/error_test'
require 'pact_broker/doc/controllers/app'


module PactBroker
module UI
class PathInfoFixer
Expand Down Expand Up @@ -41,6 +41,11 @@ def initialize
run PactBroker::UI::Controllers::Matrix
end

map "/test/error" do
use PathInfoFixer
run PactBroker::UI::Controllers::ErrorTest
end

map "/" do
run PactBroker::UI::Controllers::Index
end
Expand Down
18 changes: 18 additions & 0 deletions lib/pact_broker/ui/controllers/error_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'pact_broker/ui/controllers/base_controller'
require 'pact_broker/logging'
require 'pact_broker/error'

module PactBroker
module UI
module Controllers
class ErrorTest < Base
include PactBroker::Services
include PactBroker::Logging

get "/" do
raise PactBroker::Error.new("Don't panic. This is a test UI error.")
end
end
end
end
end

0 comments on commit 4e01407

Please sign in to comment.