Class: Inferno::DSL::SuiteEndpoint
- Inherits:
-
Hanami::Action
- Object
- Hanami::Action
- Inferno::DSL::SuiteEndpoint
- Defined in:
- lib/inferno/dsl/suite_endpoint.rb
Overview
A base class for creating endpoints to test client requests. This class is based on Hanami::Action, and may be used similarly to a normal Hanami endpoint.
Instance Attribute Summary collapse
-
#req ⇒ Object
readonly
Returns the value of attribute req.
-
#res ⇒ Object
readonly
Returns the value of attribute res.
Overrides These methods should be overridden by subclasses to define the behavior of the endpoint collapse
-
#make_response ⇒ Void
Override this method to build the response.
-
#name ⇒ String
Override this method to assign a name to the request.
-
#persist_request? ⇒ Boolean
Override this method to specify whether this request should be persisted.
-
#tags ⇒ Array<String>
Override this method to define the tags which will be applied to the request.
-
#test_run_identifier ⇒ String
Override this method to determine a test run’s identifier based on an incoming request.
-
#update_result ⇒ Void
Override this method to update the current waiting result.
Instance Method Summary collapse
-
#logger ⇒ Logger
Inferno’s logger.
-
#request ⇒ Hanami::Action::Request
The incoming request as a
Hanami::Action::Request
. -
#requests_repo ⇒ Inferno::Repositories::Requests
-
#response ⇒ Hanami::Action::Response
The response as a
Hanami::Action::Response
. -
#result ⇒ Inferno::Entities::Result
The result which is waiting for incoming requests for the current test run.
-
#results_repo ⇒ Inferno::Repositories::Results
-
#test ⇒ Inferno::Entities::Test
The test which is currently waiting for incoming requests.
-
#test_run ⇒ Inferno::Entities::TestRun
The test run which is waiting for incoming requests.
-
#test_runs_repo ⇒ Inferno::Repositories::TestRuns
-
#tests_repo ⇒ Inferno::Repositories::Tests
Instance Attribute Details
#req ⇒ Object (readonly)
Returns the value of attribute req.
61 62 63 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 61 def req @req end |
#res ⇒ Object (readonly)
Returns the value of attribute res.
61 62 63 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 61 def res @res end |
Instance Method Details
#logger ⇒ Logger
Returns Inferno’s logger.
215 216 217 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 215 def logger @logger ||= Application['logger'] end |
#make_response ⇒ Void
Override this method to build the response.
91 92 93 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 91 def make_response nil end |
#name ⇒ String
Override this method to assign a name to the request
106 107 108 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 106 def name result&.runnable&.incoming_request_name end |
#persist_request? ⇒ Boolean
Override this method to specify whether this request should be persisted. Defaults to true.
127 128 129 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 127 def persist_request? true end |
#request ⇒ Hanami::Action::Request
The incoming request as a Hanami::Action::Request
171 172 173 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 171 def request req end |
#requests_repo ⇒ Inferno::Repositories::Requests
139 140 141 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 139 def requests_repo @requests_repo ||= Inferno::Repositories::Requests.new end |
#response ⇒ Hanami::Action::Response
The response as a Hanami::Action::Response
. Modify this to build the
response to the incoming request.
185 186 187 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 185 def response res end |
#result ⇒ Inferno::Entities::Result
The result which is waiting for incoming requests for the current test run
203 204 205 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 203 def result @result ||= find_result end |
#results_repo ⇒ Inferno::Repositories::Results
144 145 146 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 144 def results_repo @results_repo ||= Inferno::Repositories::Results.new end |
#tags ⇒ Array<String>
Override this method to define the tags which will be applied to the request.
99 100 101 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 99 def @tags ||= [] end |
#test ⇒ Inferno::Entities::Test
The test which is currently waiting for incoming requests
210 211 212 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 210 def test @test ||= tests_repo.find(result.test_id) end |
#test_run ⇒ Inferno::Entities::TestRun
The test run which is waiting for incoming requests
192 193 194 195 196 197 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 192 def test_run @test_run ||= test_runs_repo.find_latest_waiting_by_identifier(find_test_run_identifier).tap do |test_run| halt 500, "Unable to find test run with identifier '#{test_run_identifier}'." if test_run.nil? end end |
#test_run_identifier ⇒ String
Override this method to determine a test run’s identifier based on an incoming request.
77 78 79 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 77 def test_run_identifier nil end |
#test_runs_repo ⇒ Inferno::Repositories::TestRuns
149 150 151 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 149 def test_runs_repo @test_runs_repo ||= Inferno::Repositories::TestRuns.new end |
#tests_repo ⇒ Inferno::Repositories::Tests
154 155 156 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 154 def tests_repo @tests_repo ||= Inferno::Repositories::Tests.new end |
#update_result ⇒ Void
Override this method to update the current waiting result. To resume the test run, set the result to something other than ‘waiting’.
119 120 121 |
# File 'lib/inferno/dsl/suite_endpoint.rb', line 119 def update_result nil end |