From: <jh...@us...> - 2011-01-14 23:54:22
|
Revision: 252 http://etch.svn.sourceforge.net/etch/?rev=252&view=rev Author: jheiss Date: 2011-01-14 23:54:16 +0000 (Fri, 14 Jan 2011) Log Message: ----------- Pull some code for fetching the latest result from the server out into a method so that we can reuse it in other tests. Modified Paths: -------------- trunk/test/etchtest.rb trunk/test/test_outputcapture.rb Modified: trunk/test/etchtest.rb =================================================================== --- trunk/test/etchtest.rb 2011-01-13 17:47:20 UTC (rev 251) +++ trunk/test/etchtest.rb 2011-01-14 23:54:16 UTC (rev 252) @@ -192,5 +192,23 @@ end end end + + # Fetch the latest result for this client from the server. Useful for + # verifying that results were logged to the server as expected. + def latest_result_message + hostname = Facter['fqdn'].value + lrm = '' + Net::HTTP.start('localhost', @server[:port]) do |http| + response = http.get("/results.xml?clients.name=#{hostname}&sort=created_at_reverse") + if !response.kind_of?(Net::HTTPSuccess) + response.error! + end + response_xml = REXML::Document.new(response.body) + if response_xml.elements['/results/result/message'] + lrm = response_xml.elements['/results/result/message'].text + end + end + lrm + end end Modified: trunk/test/test_outputcapture.rb =================================================================== --- trunk/test/test_outputcapture.rb 2011-01-13 17:47:20 UTC (rev 251) +++ trunk/test/test_outputcapture.rb 2011-01-14 23:54:16 UTC (rev 252) @@ -66,21 +66,6 @@ run_etch(@server, @testroot, :testname => testname) - # Fetch the latest result for this client from the server and verify that - # it contains the output from the post command. - hostname = Facter['fqdn'].value - latest_result_message = '' - Net::HTTP.start('localhost', @server[:port]) do |http| - response = http.get("/results.xml?clients.name=#{hostname}&sort=created_at_reverse") - if !response.kind_of?(Net::HTTPSuccess) - response.error! - end - response_xml = REXML::Document.new(response.body) - latest_result_message = nil - if response_xml.elements['/results/result/message'] - latest_result_message = response_xml.elements['/results/result/message'].text - end - end assert_match(postoutput, latest_result_message, testname) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |