Mailinglist Archive: yast-commit (1771 mails)

< Previous Next >
[yast-commit] <rest-service> network : added initial unit test
  • From: Ladislav Slezak <lslezak@xxxxxxxxxx>
  • Date: Mon, 24 Aug 2009 14:10:09 +0200
  • Message-id: <E1MiTqJ-0006bS-LI@xxxxxxxxxxxxxxxx>
ref: refs/heads/network
commit 87833e3c66a1e5541c604750ce21c24751904c80
Author: Ladislav Slezak <lslezak@xxxxxxxxxx>
Date: Mon Aug 24 14:04:13 2009 +0200

added initial unit test
---
plugins/services/test/unit/services_test.rb | 83 +++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/plugins/services/test/unit/services_test.rb
b/plugins/services/test/unit/services_test.rb
new file mode 100644
index 0000000..0221d31
--- /dev/null
+++ b/plugins/services/test/unit/services_test.rb
@@ -0,0 +1,83 @@
+require 'test_helper'
+
+require 'service'
+
+class ServiceTest < ActiveSupport::TestCase
+
+ def setup
+ end
+
+ test "read current runlevel" do
+ Service.stubs(:run_runlevel).returns("N 5")
+
+ assert Service.current_runlevel == 5
+ end
+
+ test "test uknown current runlevel" do
+ Service.stubs(:run_runlevel).returns("unknown")
+
+ assert_raise Exception do
+ Service.current_runlevel
+ end
+ end
+
+ test "find_all nil parameter" do
+ Service.stubs(:run_runlevel).returns("N 5")
+ YastService.stubs(:Call).with('YaPI::SERVICES::Read', {"runlevel" => [
"i", 5 ], "read_status" => [ "b", false]}).returns([])
+
+ ret = Service.find_all(nil)
+ assert ret == []
+ end
+
+ test "find all in unknown current runlevel" do
+ Service.stubs(:run_runlevel).returns("unknown")
+
+ assert_raise Exception do
+ Service.find_all(nil)
+ end
+ end
+
+ test "check find LSB service" do
+ srv = [{"name" => "acpid"}, {"name" => "dbus"}]
+
+ Service.stubs(:run_runlevel).returns("N 5")
+ YastService.stubs(:Call).with('YaPI::SERVICES::Read', {"runlevel" => [
"i", 5 ], "read_status" => [ "b", false]}).returns(srv)
+
+ ret = Service.find_all(Hash.new)
+ assert ret.map {|s| s.name} == ['acpid', 'dbus']
+ end
+
+
+ test "find custom service" do
+# TODO
+ end
+
+ test "check invalid custom service" do
+# TODO
+ end
+
+ test "missing command is custom service" do
+# TODO
+ end
+
+ test "check missing LSB service" do
+ ret = {"exit" => "127", "stderr" => "", "stdout" => "sh: line 1:
/etc/init.d/non_existing_service: No such file or directory\n"}
+ YastService.stubs(:Call).with('YaPI::SERVICES::Execute',
'non_existing_service', 'status').returns(ret)
+
+ s = Service.new('non_existing_service')
+ assert s.save('status') == ret
+ end
+
+ test "check LSB service status" do
+ ret = {:exit => 0}
+ YastService.stubs(:Call).with('YaPI::SERVICES::Execute', 'ntp',
'status').returns(ret)
+
+ s = Service.new('ntp')
+ assert s.save('status') == ret
+ end
+
+ test "check custom service status" do
+ end
+
+
+end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages