tdd_deploy 0.0.3 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/bin/tdd_deploy_site_installer +7 -0
  2. data/lib/tasks/tdd_deploy_site_install.rake +17 -0
  3. data/lib/tdd_deploy/assertions.rb +114 -77
  4. data/lib/tdd_deploy/base.rb +1 -1
  5. data/lib/tdd_deploy/configurator.rb +78 -0
  6. data/lib/tdd_deploy/copy_methods.rb +54 -0
  7. data/lib/tdd_deploy/deploy_test_methods.rb +20 -22
  8. data/lib/tdd_deploy/environ.rb +12 -6
  9. data/lib/tdd_deploy/host_tests/host_connection.rb +3 -4
  10. data/lib/tdd_deploy/host_tests/remote_ip_tables.rb +21 -13
  11. data/lib/tdd_deploy/host_tests/remote_monit.rb +2 -6
  12. data/lib/tdd_deploy/host_tests/remote_nginx.rb +2 -6
  13. data/lib/tdd_deploy/host_tests/remote_postfix.rb +3 -7
  14. data/lib/tdd_deploy/host_tests/remote_postgresql.rb +2 -6
  15. data/lib/tdd_deploy/run_methods.rb +25 -18
  16. data/lib/tdd_deploy/server.rb +92 -12
  17. data/lib/tdd_deploy/site_tests/site_database.rb +1 -1
  18. data/lib/tdd_deploy/site_tests/site_layout.rb +24 -20
  19. data/lib/tdd_deploy/site_tests/site_user.rb +1 -1
  20. data/lib/tdd_deploy/version.rb +1 -1
  21. data/tests/test_assertions.rb +59 -14
  22. data/tests/test_configurator.rb +34 -0
  23. data/tests/test_copy_methods.rb +106 -0
  24. data/tests/{test_test_deploy_methods.rb → test_deploy_test_methods.rb} +23 -11
  25. data/tests/test_environ.rb +12 -7
  26. data/tests/test_remote_ip_tables.rb +11 -4
  27. data/tests/test_run_methods.rb +32 -15
  28. data/tests/test_server.rb +6 -9
  29. data/tests/test_site_database.rb +21 -0
  30. data/tests/test_site_layout.rb +20 -5
  31. data/tests/test_tdd_deploy_context.rb +16 -0
  32. data/tests/test_tdd_deploy_server.rb +3 -3
  33. metadata +20 -13
  34. data/tests/test_colored_tests.rb +0 -47
data/tests/test_server.rb CHANGED
@@ -6,24 +6,20 @@ require 'tdd_deploy/run_methods'
6
6
  class TestServerTestCase < Test::Unit::TestCase
7
7
  GEM_ROOT = File.expand_path('../..', __FILE__)
8
8
  BIN_DIR = File.join(GEM_ROOT, 'bin')
9
- PORT = 8809
10
9
 
11
10
  include TddDeploy::RunMethods
12
11
 
13
12
  def setup
14
13
  require 'tdd_deploy/server'
15
- @tester = TddDeploy::Server.new(PORT, :web_hosts => 'arch', :db_hosts => 'arch',
16
- :host_admin => 'mike', :local_admin => 'mike', :ssh_timeout => 2)
14
+ @tester = TddDeploy::Server.new(:web_hosts => 'arch', :db_hosts => 'arch',
15
+ :host_admin => 'mike', :local_admin => 'mike', :ssh_timeout => 2,
16
+ :site => 'site', :site_user => 'site_user')
17
17
  end
18
18
 
19
19
  def teardown
20
20
  @tester = nil
21
21
  end
22
22
 
23
- def test_tester_accessors
24
- assert_equal PORT, @tester.port, "@tester.port should be #{PORT}"
25
- end
26
-
27
23
  def test_classes_array
28
24
  @tester.load_all_tests
29
25
  assert_not_nil @tester.test_classes, "@tester.test_classes should not be nil"
@@ -32,8 +28,9 @@ class TestServerTestCase < Test::Unit::TestCase
32
28
 
33
29
  def test_run_all_tests
34
30
  ret = @tester.run_all_tests
35
- assert ret, "@tester should run all tests and return true: #{@tester.test_failures}"
36
- # puts @tester.test_results
31
+ failures = "\n" + (@tester.failure_messages('arch') || []).join("\n") + "\n"
32
+ assert ret, "@tester should run all tests and return true: returned: #{ret.inspect}: #{failures}"
33
+ # puts @tester.formatted_test_results
37
34
  end
38
35
 
39
36
  def test_rack_interface
@@ -0,0 +1,21 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ require 'test_helpers'
3
+ require 'tdd_deploy/site_tests/site_database'
4
+
5
+ class TestSiteDatabaseTestCase < Test::Unit::TestCase
6
+ def setup
7
+ @tester = TddDeploy::SiteDatabase.new
8
+ @tester.reset_env
9
+ @tester.set_env :hosts => 'arch', :host_admin => 'mike', :local_admin => 'mike'
10
+ end
11
+
12
+ def teardown
13
+ @tester = nil
14
+ end
15
+
16
+ def test_site_database_test
17
+ assert @tester.test_site_db_defined, "Site database #{@tester.site} defined"
18
+ end
19
+ end
20
+
21
+
@@ -15,20 +15,35 @@ class TestSiteLayoutTestCase < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  def test_site_home
18
- assert @tester.test_site_subdir, "Directory /home/#{@tester.site_user}/#{@tester.site} should exist"
18
+ assert @tester.test_site_subdir, "Directory /home/#{@tester.site_user}/#{@tester.site}.d should exist"
19
19
  end
20
20
 
21
21
  def test_site_releases
22
- assert @tester.test_releases_subdir, "Directory /home/#{@tester.site_user}/#{@tester.site}/releases should exist"
22
+ assert @tester.test_releases_subdir, "Directory /home/#{@tester.site_user}/#{@tester.site}.d/releases should exist"
23
23
  end
24
24
 
25
+ def test_site_configuration_dir_exists
26
+ assert @tester.test_site_dir_exists, @tester.formatted_test_results
27
+ end
28
+
25
29
  def test_site_nginx_conf
26
- assert @tester.test_nginx_conf, "Directory /home/#{@tester.site_user}/nginx_conf should exist"
30
+ assert @tester.test_nginx_conf, "Directory /home/#{@tester.site_user}/site/nginx_conf should exist"
27
31
  end
28
32
 
29
33
  def test_site_monitrc
30
- assert @tester.test_monitrc, "Directory /home/#{@tester.site_user}/monitrc should exist"
34
+ assert @tester.test_monitrc, "Directory /home/#{@tester.site_user}/site/monitrc should exist"
35
+ end
36
+
37
+ def test_test_thin_conf
38
+ assert @tester.test_thin_conf, @tester.formatted_test_results
31
39
  end
32
- end
33
40
 
41
+ def test_test_one_thin_server_conf
42
+ assert @tester.test_one_thin_server_conf, @tester.formatted_test_results
43
+ end
34
44
 
45
+ def test_test_one_thin_server
46
+ assert @tester.test_one_thin_server, @tester.formatted_test_results
47
+ end
48
+
49
+ end
@@ -4,12 +4,28 @@ require 'test/unit'
4
4
  require 'tdd_deploy/environ'
5
5
  require 'tdd_deploy/run_methods'
6
6
 
7
+ class TddDeployContextHelper
8
+ include TddDeploy::Environ
9
+ end
10
+
7
11
  class TestTddDeployContextTestCase < Test::Unit::TestCase
8
12
  GEM_ROOT = File.expand_path('../..', __FILE__)
9
13
  BIN_DIR = File.join(GEM_ROOT, 'bin')
10
14
 
11
15
  include TddDeploy::RunMethods
12
16
 
17
+ def setup
18
+ @helper = TddDeployContextHelper.new
19
+ @helper.reset_env
20
+ @helper.save_env
21
+ end
22
+
23
+ def teardown
24
+ @helper.reset_env
25
+ @helper.save_env
26
+ @helper = nil
27
+ end
28
+
13
29
  def test_set_env_rb_exists
14
30
  assert File.exists?(File.join(BIN_DIR, 'tdd_deploy_context')), "tdd_deploy_context exists"
15
31
  end
@@ -21,7 +21,7 @@ class TestTddDeployServerTestCase < Test::Unit::TestCase
21
21
  # end
22
22
 
23
23
  def test_set_env_rb_exists
24
- assert File.exists?(File.join(BIN_DIR, 'tdd_deploy_server.rb')), "tdd_deploy_server exists"
24
+ assert File.exists?(File.join(BIN_DIR, 'tdd_deploy_server')), "tdd_deploy_server exists"
25
25
  end
26
26
  #
27
27
  # def test_tester_accessors
@@ -36,8 +36,8 @@ class TestTddDeployServerTestCase < Test::Unit::TestCase
36
36
  #
37
37
  # def test_run_all_tests
38
38
  # ret = @tester.run_all_tests
39
- # assert ret, "@tester should run all tests and return true: #{@tester.test_failures}"
40
- # # puts @tester.test_results
39
+ # assert ret, "@tester should run all tests and return true: #{@tester.failure_messages}"
40
+ # # puts @tester.formatted_test_results
41
41
  # end
42
42
  #
43
43
  # def test_rack_interface
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdd_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-08-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: &2165241880 !ruby/object:Gem::Requirement
16
+ requirement: &2153541160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2165241880
24
+ version_requirements: *2153541160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: net-ping
27
- requirement: &2165241380 !ruby/object:Gem::Requirement
27
+ requirement: &2153540580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2165241380
35
+ version_requirements: *2153540580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: net-ssh
38
- requirement: &2165240900 !ruby/object:Gem::Requirement
38
+ requirement: &2153540040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2165240900
46
+ version_requirements: *2153540040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ZenTest
49
- requirement: &2165240340 !ruby/object:Gem::Requirement
49
+ requirement: &2153539420 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 4.5.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2165240340
57
+ version_requirements: *2153539420
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: autotest-growl
60
- requirement: &2165239920 !ruby/object:Gem::Requirement
60
+ requirement: &2153538880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,13 +65,14 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2165239920
68
+ version_requirements: *2153538880
69
69
  description: Test driven support for host provisioning & Capistrano deployment - for
70
70
  those who don't want to bother learning too much
71
71
  email: ! ' mike@clove.com '
72
72
  executables:
73
73
  - tdd_deploy_context
74
74
  - tdd_deploy_server
75
+ - tdd_deploy_site_installer
75
76
  extensions: []
76
77
  extra_rdoc_files: []
77
78
  files:
@@ -80,8 +81,11 @@ files:
80
81
  - config.ru
81
82
  - bin/tdd_deploy_context
82
83
  - bin/tdd_deploy_server
84
+ - bin/tdd_deploy_site_installer
83
85
  - lib/tdd_deploy/assertions.rb
84
86
  - lib/tdd_deploy/base.rb
87
+ - lib/tdd_deploy/configurator.rb
88
+ - lib/tdd_deploy/copy_methods.rb
85
89
  - lib/tdd_deploy/deploy_test_methods.rb
86
90
  - lib/tdd_deploy/environ.rb
87
91
  - lib/tdd_deploy/host_tests/host_connection.rb
@@ -100,7 +104,9 @@ files:
100
104
  - lib/tdd_deploy.rb
101
105
  - tests/test_assertions.rb
102
106
  - tests/test_base.rb
103
- - tests/test_colored_tests.rb
107
+ - tests/test_configurator.rb
108
+ - tests/test_copy_methods.rb
109
+ - tests/test_deploy_test_methods.rb
104
110
  - tests/test_environ.rb
105
111
  - tests/test_helpers.rb
106
112
  - tests/test_host_tests.rb
@@ -111,13 +117,14 @@ files:
111
117
  - tests/test_remote_postgresql.rb
112
118
  - tests/test_run_methods.rb
113
119
  - tests/test_server.rb
120
+ - tests/test_site_database.rb
114
121
  - tests/test_site_layout.rb
115
122
  - tests/test_site_user.rb
116
123
  - tests/test_tdd_deploy.rb
117
124
  - tests/test_tdd_deploy_context.rb
118
125
  - tests/test_tdd_deploy_server.rb
119
- - tests/test_test_deploy_methods.rb
120
126
  - lib/tasks/tdd_deploy.rake
127
+ - lib/tasks/tdd_deploy_site_install.rake
121
128
  homepage: https://github.com/mikehoward/tdd_deploy
122
129
  licenses:
123
130
  - GPL3
@@ -1,47 +0,0 @@
1
- $:.unshift File.expand_path('..', __FILE__)
2
- require 'test_helpers'
3
- require 'tdd_deploy/base'
4
-
5
- # NOTES: These tests require a host to talk to. I run an Arch Linux server on my local
6
- # machine as a virtual host. Set up your own with appropriate accounts if you need to run
7
- # these tests.
8
-
9
- class ColoredResult < TddDeploy::Base
10
- def passing_test
11
- deploy_test_on_all_hosts 'true', 'true always passes' do
12
- 'echo "true"'
13
- end
14
- end
15
-
16
- def failing_test
17
- deploy_test_on_all_hosts 'false', 'false always fails' do
18
- 'echo "true"'
19
- end
20
- end
21
- end
22
-
23
- class ColoredResultTestCase < Test::Unit::TestCase
24
- def setup
25
- @tester = ColoredResult.new( { :host_admin => 'mike', :local_admin => 'mike', :db_hosts => 'arch',
26
- :web_hosts => 'arch', :ssh_timeout => 2 } )
27
- @tester.reset_tests
28
- end
29
-
30
- def teardown
31
- @tester = nil
32
- # we need to delete this guy so it doesn't mess up the testing of server.rb
33
- TddDeploy::Base.children.delete ColoredResult
34
- end
35
-
36
- def test_passing_result
37
- @tester.passing_test
38
- test_results = @tester.test_results
39
- assert_match 'style="color:#0c0"', test_results, "Passing Test result should be colored Green: color:#0c0"
40
- end
41
-
42
- def test_failing_result
43
- @tester.failing_test
44
- test_results = @tester.test_results
45
- assert_match 'style="color:#c00"', test_results, "Passing Test result should be colored Red: color:#c00"
46
- end
47
- end