Skip to content

Commit

Permalink
[buddhi] metric_reporter_spec: response body format update
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Jun 5, 2018
1 parent 4a287fd commit ec47a71
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 11 additions & 1 deletion buddhi/spec/metric_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@
expect(test_plan).to receive(:metric_report).with('a533908aa896', '/1').and_return('base' => 1, 'metric_1' => 3)
expect(test_plan).to receive(:metric_report).with('cb0a88b8da15', '/1').and_return('base' => 1, 'metric_2' => 2)
expect(test_plan).to receive(:metric_report).with('a533908aa896', '/11').and_return('base' => 2, 'metric_1' => 3, 'metric_3' => 1)
expect(subject.report(data)).to eq('base' => 4, 'metric_1' => 6, 'metric_3' => 1, 'metric_2' => 2)
expect(subject.report(data)).to eq(
'a533908aa896' => {
'base' => 3,
'metric_1' => 6,
'metric_3' => 1
},
'cb0a88b8da15' => {
'base' => 1,
'metric_2' => 2
}
)
end
end
end
9 changes: 4 additions & 5 deletions buddhi/spec/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@
it 'amp_report method returns metrics report' do
expect(test_plan).to receive(:http_port).and_return(6664)
body = '"82755f4b.benchmark.3sca.net","/1?user_key=86fafe7d3702f36d"'
expect(metric_reporter).to receive(:report).with(body).and_return('REPORT')
req = server_build_post_request('/report/amp',
body)
expected_resp_body = { 'svc_a' => { 'm_a' => 1 } }
expect(metric_reporter).to receive(:report).with(body).and_return(expected_resp_body)
req = server_build_post_request('/report/amp', body)
server.amp_report(req, resp)
# Check returned services are expected ones
expect(resp.body).to be
parsed_response = JSON.parse(resp.body)
expect(parsed_response).to have_key('metrics')
expect(parsed_response['metrics']).to eq('REPORT')
expect(parsed_response).to eq(expected_resp_body)
end
end
end

0 comments on commit ec47a71

Please sign in to comment.