ref: refs/heads/master
commit 5af97e08aa54931a768bb6335766be7e91947a67
Author: Ladislav Slezak
Date: Thu Sep 3 15:43:55 2009 +0200
test no resource exception
removed empty test file
---
.../test/functional/services_controller_test.rb | 22 +++++++++++++++++++-
plugins/services/test/services_test.rb | 8 -------
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/plugins/services/test/functional/services_controller_test.rb b/plugins/services/test/functional/services_controller_test.rb
index 07870ca..67d5c40 100644
--- a/plugins/services/test/functional/services_controller_test.rb
+++ b/plugins/services/test/functional/services_controller_test.rb
@@ -9,6 +9,13 @@ class ServicesControllerTest < ActionController::TestCase
end
end
+ class Proxy2
+ attr_accessor :result, :permissions, :timeout
+ def find(params = {})
+ raise ActiveResource::ResourceNotFound.new(Net::HTTPNotFound.new('1.1', '404', 'Not Found '))
+ end
+ end
+
class Result
attr_accessor :status
@@ -37,10 +44,13 @@ class ServicesControllerTest < ActionController::TestCase
@proxy.permissions = @permissions
@proxy.result = @result
- YaST::ServiceResource.stubs(:proxy_for).with('org.opensuse.yast.modules.yapi.services').returns(@proxy)
+ @proxy2 = Proxy2.new
+ @proxy2.permissions = @permissions
+ @proxy2.result = @result
end
def test_should_get_index
+ YaST::ServiceResource.stubs(:proxy_for).with('org.opensuse.yast.modules.yapi.services').returns(@proxy)
get :index
assert_response :success
assert_not_nil assigns(:services)
@@ -48,9 +58,19 @@ class ServicesControllerTest < ActionController::TestCase
def test_ntp_status
+ YaST::ServiceResource.stubs(:proxy_for).with('org.opensuse.yast.modules.yapi.services').returns(@proxy)
ret = get :show_status, {:id => 'ntp'}
assert_response :success
assert ret.body == '(running)'
end
+ def test_missing_service_status
+ Net::HTTPNotFound.any_instance.stubs(:body).returns("<error><code>108</code><message>Missing custom command to 'status' command</message></error>")
+ YaST::ServiceResource.stubs(:proxy_for).with('org.opensuse.yast.modules.yapi.services').returns(@proxy2)
+ ret = get :show_status, {:id => 'aaaaaaaa'}
+ assert_response :success
+ assert ret.body == '(cannot read status)'
+ end
+
end
+
diff --git a/plugins/services/test/services_test.rb b/plugins/services/test/services_test.rb
deleted file mode 100644
index 2b7f0a4..0000000
--- a/plugins/services/test/services_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class ServicesTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org