sanford 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +1 -0
- data/lib/sanford/cli.rb +1 -270
- data/lib/sanford/host.rb +12 -14
- data/lib/sanford/host_data.rb +7 -7
- data/lib/sanford/manager.rb +275 -0
- data/lib/sanford/runner.rb +39 -32
- data/lib/sanford/server.rb +1 -0
- data/lib/sanford/service_handler.rb +54 -41
- data/lib/sanford/test_helpers.rb +19 -0
- data/lib/sanford/test_runner.rb +17 -12
- data/lib/sanford/version.rb +1 -1
- data/lib/sanford.rb +19 -17
- data/sanford.gemspec +5 -5
- data/test/support/service_handlers.rb +69 -43
- data/test/support/services.rb +2 -2
- data/test/support/simple_client.rb +2 -2
- data/test/system/request_handling_tests.rb +2 -2
- data/test/unit/error_handler_tests.rb +13 -12
- data/test/unit/host_data_tests.rb +26 -14
- data/test/unit/host_tests.rb +105 -16
- data/test/unit/manager_tests.rb +103 -50
- data/test/unit/runner_tests.rb +6 -3
- data/test/unit/sanford_tests.rb +70 -0
- data/test/unit/server_tests.rb +8 -6
- data/test/unit/service_handler_tests.rb +179 -68
- data/test/unit/worker_tests.rb +6 -5
- metadata +32 -74
- data/test/unit/config_tests.rb +0 -12
- data/test/unit/host_configuration_tests.rb +0 -37
- data/test/unit/hosts_tests.rb +0 -56
- data/test/unit/manager_pid_file_tests.rb +0 -60
data/test/unit/hosts_tests.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'assert'
|
2
|
-
|
3
|
-
class Sanford::Hosts
|
4
|
-
|
5
|
-
class BaseTests < Assert::Context
|
6
|
-
desc "Sanford::hosts"
|
7
|
-
setup do
|
8
|
-
@hosts = Sanford::Hosts.new
|
9
|
-
end
|
10
|
-
subject{ @hosts }
|
11
|
-
|
12
|
-
should have_instance_methods :add, :first, :find
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
class FindTests < BaseTests
|
17
|
-
desc "find"
|
18
|
-
setup do
|
19
|
-
@hosts.add ::NotNamedHost
|
20
|
-
@hosts.add ::NamedHost
|
21
|
-
@hosts.add ::BadlyNamedHost
|
22
|
-
end
|
23
|
-
|
24
|
-
should "allow finding hosts by their class name or configured name" do
|
25
|
-
assert_includes NotNamedHost, subject
|
26
|
-
assert_includes NamedHost, subject
|
27
|
-
assert_equal NotNamedHost, subject.find('NotNamedHost')
|
28
|
-
assert_equal NamedHost, subject.find('NamedHost')
|
29
|
-
assert_equal NamedHost, subject.find('named_host')
|
30
|
-
end
|
31
|
-
|
32
|
-
should "check class name before configured name" do
|
33
|
-
assert_includes BadlyNamedHost, subject
|
34
|
-
assert_equal NotNamedHost, subject.find('NotNamedHost')
|
35
|
-
end
|
36
|
-
|
37
|
-
# Using this syntax because these classes need to be defined as top-level
|
38
|
-
# constants for ease in using their class names in the tests
|
39
|
-
|
40
|
-
::NotNamedHost = Class.new do
|
41
|
-
include Sanford::Host
|
42
|
-
end
|
43
|
-
|
44
|
-
::NamedHost = Class.new do
|
45
|
-
include Sanford::Host
|
46
|
-
name 'named_host'
|
47
|
-
end
|
48
|
-
|
49
|
-
::BadlyNamedHost = Class.new do
|
50
|
-
include Sanford::Host
|
51
|
-
name 'NotNamedHost'
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'assert'
|
2
|
-
require 'sanford/cli'
|
3
|
-
|
4
|
-
class Sanford::Manager::PIDFile
|
5
|
-
|
6
|
-
class BaseTests < Assert::Context
|
7
|
-
desc "Sanford::Manager::PIDFile"
|
8
|
-
setup do
|
9
|
-
@pid_file_path = File.join(ROOT, "tmp/my.pid")
|
10
|
-
@pid_file = Sanford::Manager::PIDFile.new(@pid_file_path)
|
11
|
-
end
|
12
|
-
teardown do
|
13
|
-
FileUtils.rm_rf(@pid_file_path)
|
14
|
-
end
|
15
|
-
subject{ @pid_file }
|
16
|
-
|
17
|
-
should have_instance_methods :pid, :to_s, :write, :remove
|
18
|
-
|
19
|
-
should "return it's path with #to_s" do
|
20
|
-
assert_equal @pid_file_path, subject.to_s
|
21
|
-
end
|
22
|
-
|
23
|
-
should "write the pid file with #write" do
|
24
|
-
subject.write
|
25
|
-
|
26
|
-
assert_file_exists @pid_file_path
|
27
|
-
assert_equal "#{Process.pid}\n", File.read(@pid_file_path)
|
28
|
-
end
|
29
|
-
|
30
|
-
should "return the value stored in the pid value with #pid" do
|
31
|
-
subject.write
|
32
|
-
|
33
|
-
assert_equal Process.pid, subject.pid
|
34
|
-
end
|
35
|
-
|
36
|
-
should "remove the file with #remove" do
|
37
|
-
subject.write
|
38
|
-
subject.remove
|
39
|
-
|
40
|
-
assert_not File.exists?(@pid_file_path)
|
41
|
-
end
|
42
|
-
|
43
|
-
should "complain nicely if it can't write the pid file" do
|
44
|
-
pid_file_path = 'does/not/exist.pid'
|
45
|
-
pid_file = Sanford::Manager::PIDFile.new(pid_file_path)
|
46
|
-
|
47
|
-
err = nil
|
48
|
-
begin
|
49
|
-
pid_file.write
|
50
|
-
rescue Exception => err
|
51
|
-
end
|
52
|
-
|
53
|
-
assert err
|
54
|
-
assert_kind_of RuntimeError, err
|
55
|
-
assert_includes File.dirname(pid_file_path), err.message
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|