[Ovirt-devel] [PATCH server] Fixed the tests for host-browser.

Darryl L. Pierce dpierce at redhat.com
Thu Oct 2 18:19:56 UTC 2008


A change to the identify protocol was overlooked. When an empty value was
submitted, host-browser would throw an exception. But, a change allowed
empty values to get by without notice. Fixed.

Also added a Requires dependency on ruby-flexmock so that the RPM is
correctly installed when building the server RPM.

Finally, reintroduced a line that was deleted by mistaken from NicControllerTest.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 ovirt-server.spec.in                        |    1 +
 src/host-browser/host-browser.rb            |    9 +++++++--
 src/test/functional/nic_controller_test.rb  |    2 ++
 src/test/unit/host_browser_awaken_test.rb   |    3 +++
 src/test/unit/host_browser_identify_test.rb |    3 +++
 5 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/ovirt-server.spec.in b/ovirt-server.spec.in
index 114b52d..1339b52 100644
--- a/ovirt-server.spec.in
+++ b/ovirt-server.spec.in
@@ -19,6 +19,7 @@ Requires: rubygem(mongrel) >= 1.0.1
 Requires: rubygem(krb5-auth) >= 0.6
 Requires: rubygem(cobbler) >= 0.0.2
 Requires: rubygem(gettext)
+Requires: ruby-flexmock
 Requires: postgresql-server
 Requires: ruby-postgres
 Requires: xapian-bindings-ruby
diff --git a/src/host-browser/host-browser.rb b/src/host-browser/host-browser.rb
index 3adea03..2241614 100755
--- a/src/host-browser/host-browser.rb
+++ b/src/host-browser/host-browser.rb
@@ -46,10 +46,15 @@ class HostBrowser
     def initialize(session)
         @session = session
         @keytab_dir = '/usr/share/ipa/html/'
+        set_peeraddr @session.peeraddr[3]
+    end
+
+    def set_peeraddr(peeraddr)
+      @peeraddr = peeraddr
     end
 
     def prefix(session)
-      "#{Time.now.strftime('%b %d %H:%M:%S')} #{session.peeraddr[3]} "
+      "#{Time.now.strftime('%b %d %H:%M:%S')} #{@peeraddr} "
     end
 
     # Ensures the conversation starts properly.
@@ -113,7 +118,7 @@ class HostBrowser
                 nic_info << nic
             else
 
-                raise Exception.new("ERRINFO! Expected key=value : #{info}\n") unless info =~ /[\w]+[\s]*=[\w]*/
+                raise Exception.new("ERRINFO! Expected key=value : #{info}\n") unless info =~ /[\w]+[\s]*=[\w]+/
 
                 key, value = info.split("=")
 
diff --git a/src/test/functional/nic_controller_test.rb b/src/test/functional/nic_controller_test.rb
index 74a80f4..1fa34ff 100644
--- a/src/test/functional/nic_controller_test.rb
+++ b/src/test/functional/nic_controller_test.rb
@@ -30,6 +30,8 @@ class NicControllerTest < Test::Unit::TestCase
     @controller = NicController.new
     @request    = ActionController::TestRequest.new
     @response   = ActionController::TestResponse.new
+    
+    @first_id = nics(:one).id
   end
 
   def test_show
diff --git a/src/test/unit/host_browser_awaken_test.rb b/src/test/unit/host_browser_awaken_test.rb
index 5340e01..53711ee 100644
--- a/src/test/unit/host_browser_awaken_test.rb
+++ b/src/test/unit/host_browser_awaken_test.rb
@@ -18,6 +18,9 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
+$: << File.join(File.dirname(__FILE__), "../../dutils")
+$: << File.join(File.dirname(__FILE__), "../../host-browser")
+ 
 require File.dirname(__FILE__) + '/../test_helper'
 require 'test/unit'
 require 'flexmock/test_unit'
diff --git a/src/test/unit/host_browser_identify_test.rb b/src/test/unit/host_browser_identify_test.rb
index 87c6f0b..86f5a73 100644
--- a/src/test/unit/host_browser_identify_test.rb
+++ b/src/test/unit/host_browser_identify_test.rb
@@ -18,6 +18,9 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
+$: << File.join(File.dirname(__FILE__), "../../dutils")
+$: << File.join(File.dirname(__FILE__), "../../host-browser")
+ 
 require File.dirname(__FILE__) + '/../test_helper'
 
 require 'test/unit'
-- 
1.5.5.1




More information about the ovirt-devel mailing list