This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "YaST web service".
The branch, master has been updated
via 8c1e2ffef0bfeeef83f09f4732dd1f61beb2fb03 (commit)
via bbade1ede8686d0d42679855865d9bbab28982fa (commit)
via 054a7488101263b93c85c4fde52fc7ea5c5c2931 (commit)
from aaba41ea3119b6f6239edc62072ddcb43c675f5d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8c1e2ffef0bfeeef83f09f4732dd1f61beb2fb03
Author: Klaus Kämpf
Date: Fri Jun 26 13:40:34 2009 +0200
Enhance resource registration testing, now 93.6% coverage
commit bbade1ede8686d0d42679855865d9bbab28982fa
Merge: 054a7488101263b93c85c4fde52fc7ea5c5c2931 aaba41ea3119b6f6239edc62072ddcb43c675f5d
Author: Klaus Kämpf
Date: Fri Jun 26 11:39:49 2009 +0200
Merge branch 'master' of git@git.opensuse.org:projects/yast/rest-service
commit 054a7488101263b93c85c4fde52fc7ea5c5c2931
Author: Klaus Kämpf
Date: Fri Jun 26 11:39:36 2009 +0200
remove duplicate def for reset
-----------------------------------------------------------------------
Summary of changes and diff:
webservice/lib/resource_registration.rb | 10 +++---
.../test/functional/resource_registration_test.rb | 37 ++++++++++++++++++++
2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/webservice/lib/resource_registration.rb b/webservice/lib/resource_registration.rb
index b93c1bb..8bfaa98 100644
--- a/webservice/lib/resource_registration.rb
+++ b/webservice/lib/resource_registration.rb
@@ -5,6 +5,7 @@ class ResourceRegistration
def self.resources
@@resources
end
+
private
def self.error msg
if @@in_production
@@ -14,6 +15,7 @@ private
raise msg
end
end
+
public
#
# reset registered resources
@@ -28,10 +30,6 @@ public
# optionally the interface and controller can be passed
# otherwise they are read from the yml file
#
-public
- def self.reset
- @@resources = Hash.new
- end
def self.register(file, interface = nil, controller = nil)
# $stderr.puts "register #{file}"
@@ -41,10 +39,12 @@ public
begin
resource = YAML.load(File.open(file)) || Hash.new
rescue Exception => e
- $stderr.puts "#{file} failed to load"
+ $stderr.puts "#{file} failed to load: #{$!}"
raise # re-raise
end
+ error "#{file} has wrong format" unless resource.is_a? Hash
+
# interface: can override
interface = resource['interface'] || interface
error "#{file} does not specify interface" unless interface
diff --git a/webservice/test/functional/resource_registration_test.rb b/webservice/test/functional/resource_registration_test.rb
index b5724c7..322dd64 100644
--- a/webservice/test/functional/resource_registration_test.rb
+++ b/webservice/test/functional/resource_registration_test.rb
@@ -69,4 +69,41 @@ class ResourceRegistrationTest < ActiveSupport::TestCase
ResourceRegistration.register_plugin plugin
end
end
+
+ # Pass bad values to register_plugin
+
+ test "pass bad values to register_plugin" do
+ assert_raise NoMethodError do
+ ResourceRegistration.register_plugin nil
+ end
+ assert_raise NoMethodError do
+ ResourceRegistration.register_plugin 1
+ end
+ assert_raise NoMethodError do
+ ResourceRegistration.register_plugin true
+ end
+ end
+
+ # Catch non-existing file
+
+ test "file does not exist" do
+ assert_raise Errno::ENOENT do
+ ResourceRegistration.register "does_not_exist"
+ end
+ end
+
+ # Bad call to register
+
+ test "passing bad values to register" do
+ assert_raise TypeError do
+ ResourceRegistration.register nil
+ end
+ assert_raise TypeError do
+ ResourceRegistration.register 1
+ end
+ assert_raise TypeError do
+ ResourceRegistration.register true
+ end
+ end
+
end
hooks/post-receive
--
YaST web service
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org