dk-abdeploy 0.0.1 → 0.1.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.
@@ -0,0 +1,41 @@
1
+ require 'assert'
2
+ require 'dk-abdeploy/utils/current_git_branch'
3
+
4
+ require 'dk/task'
5
+
6
+ module Dk::ABDeploy::Utils::CurrentGitBranch
7
+
8
+ class UnitTests < Assert::Context
9
+ include Dk::Task::TestHelpers
10
+
11
+ desc "Dk::ABDeploy::Utils::CurrentGitBranch"
12
+ setup do
13
+ @current_git_branch = Dk::ABDeploy::Utils::CurrentGitBranch
14
+ end
15
+ subject{ @current_git_branch }
16
+
17
+ should "return the cmd str to lookup the current git branch if no block given" do
18
+ assert_equal "git symbolic-ref HEAD", subject.new
19
+ end
20
+
21
+ should "yield the cmd str and expect a local cmd obj returned if a block given" do
22
+ task_class = Class.new do
23
+ include Dk::Task
24
+
25
+ def run!
26
+ ref = Dk::ABDeploy::Utils::CurrentGitBranch.new{ |cmd_str| cmd! cmd_str }
27
+ set_param 'git_ref', ref
28
+ end
29
+ end
30
+ runner = test_runner(task_class)
31
+
32
+ branch_name = Factory.string
33
+ runner.stub_cmd(subject.new){ |spy| spy.stdout = "refs/heads/#{branch_name}" }
34
+ runner.run
35
+
36
+ assert_equal branch_name, runner.params['git_ref']
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,137 @@
1
+ require 'assert'
2
+ require 'dk-abdeploy/validate'
3
+
4
+ require 'dk/task'
5
+ require 'dk-abdeploy'
6
+
7
+ class Dk::ABDeploy::Validate
8
+
9
+ class UnitTests < Assert::Context
10
+ desc "Dk::ABDeploy::Validate"
11
+ setup do
12
+ @task_class = Dk::ABDeploy::Validate
13
+ end
14
+ subject{ @task_class }
15
+
16
+ should "be a Dk task" do
17
+ assert_includes Dk::Task, subject
18
+ end
19
+
20
+ should "know its description" do
21
+ exp = "(dk-abdeploy) validate the required dk-abdeploy params"
22
+ assert_equal exp, subject.description
23
+ end
24
+
25
+ should "run only once" do
26
+ assert_true subject.run_only_once
27
+ end
28
+
29
+ end
30
+
31
+ class RunTests < UnitTests
32
+ include Dk::Task::TestHelpers
33
+
34
+ desc "when run"
35
+ setup do
36
+ @root = Factory.path
37
+ @repo = Factory.string
38
+
39
+ @params = {
40
+ Dk::ABDeploy::ROOT_PARAM_NAME => @root,
41
+ Dk::ABDeploy::REPO_PARAM_NAME => @repo
42
+ }
43
+ @runner = test_runner(@task_class, :params => @params)
44
+
45
+ @hosts = Factory.integer(3).times.map{ Factory.string }
46
+ @runner.ssh_hosts(Dk::ABDeploy::SSH_HOSTS_GROUP_NAME, @hosts)
47
+
48
+ @runner.run
49
+ end
50
+ subject{ @runner }
51
+
52
+ should "set some params based on the root param" do
53
+ exp = File.join(@root, Dk::ABDeploy::SHARED_DIR_NAME)
54
+ assert_equal exp, subject.params[Dk::ABDeploy::SHARED_DIR_PARAM_NAME]
55
+
56
+ exp = File.join(@root, Dk::ABDeploy::CURRENT_LINK_NAME)
57
+ assert_equal exp, subject.params[Dk::ABDeploy::CURRENT_DIR_PARAM_NAME]
58
+
59
+ exp = File.join(@root, Dk::ABDeploy::RELEASES_DIR_NAME)
60
+ assert_equal exp, subject.params[Dk::ABDeploy::RELEASES_DIR_PARAM_NAME]
61
+
62
+ exp_releases_dir = exp
63
+
64
+ exp = File.join(exp_releases_dir, Dk::ABDeploy::RELEASE_A_DIR_NAME)
65
+ assert_equal exp, subject.params[Dk::ABDeploy::RELEASE_A_DIR_PARAM_NAME]
66
+
67
+ exp = File.join(exp_releases_dir, Dk::ABDeploy::RELEASE_B_DIR_NAME)
68
+ assert_equal exp, subject.params[Dk::ABDeploy::RELEASE_B_DIR_PARAM_NAME]
69
+ end
70
+
71
+ should "complain if the root/repo params aren't set" do
72
+ value = [nil, ''].sample
73
+
74
+ @params[@params.keys.sample] = value
75
+ runner = test_runner(@task_class, :params => @params)
76
+ assert_raises(ArgumentError){ runner.run }
77
+ end
78
+
79
+ should "complain if the ssh hosts aren't set" do
80
+ runner = test_runner(@task_class, :params => @params)
81
+ assert_raises(ArgumentError){ runner.run }
82
+ end
83
+
84
+ end
85
+
86
+ class TestHelpersTests < UnitTests
87
+ desc "TestHelpers"
88
+ setup do
89
+ @context_class = Class.new do
90
+ def self.setup_blocks; @setup_blocks ||= []; end
91
+ def self.setup(&block)
92
+ self.setup_blocks << block
93
+ end
94
+ include Dk::ABDeploy::Validate::TestHelpers
95
+ attr_reader :dk_abdeploy_root, :dk_abdeploy_repo
96
+ attr_reader :dk_abdeploy_shared, :dk_abdeploy_current
97
+ attr_reader :dk_abdeploy_releases
98
+ attr_reader :dk_abdeploy_release_a, :dk_abdeploy_release_b
99
+ attr_reader :params
100
+ def initialize
101
+ self.class.setup_blocks.each{ |b| self.instance_eval(&b) }
102
+ end
103
+ end
104
+ @context = @context_class.new
105
+ end
106
+ subject{ @context }
107
+
108
+ should "use much-plugin" do
109
+ assert_includes MuchPlugin, @context_class
110
+ end
111
+
112
+ should "setup the ivars and params the validate task does" do
113
+ exp = subject.dk_abdeploy_root
114
+ assert_equal exp, subject.params[Dk::ABDeploy::ROOT_PARAM_NAME]
115
+
116
+ exp = subject.dk_abdeploy_repo
117
+ assert_equal exp, subject.params[Dk::ABDeploy::REPO_PARAM_NAME]
118
+
119
+ exp = subject.dk_abdeploy_shared
120
+ assert_equal exp, subject.params[Dk::ABDeploy::SHARED_DIR_PARAM_NAME]
121
+
122
+ exp = subject.dk_abdeploy_current
123
+ assert_equal exp, subject.params[Dk::ABDeploy::CURRENT_DIR_PARAM_NAME]
124
+
125
+ exp = subject.dk_abdeploy_releases
126
+ assert_equal exp, subject.params[Dk::ABDeploy::RELEASES_DIR_PARAM_NAME]
127
+
128
+ exp = subject.dk_abdeploy_release_a
129
+ assert_equal exp, subject.params[Dk::ABDeploy::RELEASE_A_DIR_PARAM_NAME]
130
+
131
+ exp = subject.dk_abdeploy_release_b
132
+ assert_equal exp, subject.params[Dk::ABDeploy::RELEASE_B_DIR_PARAM_NAME]
133
+ end
134
+
135
+ end
136
+
137
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dk-abdeploy
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: &id002 !ruby/object:Gem::Version
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2016-07-12 00:00:00 Z
13
+ date: 2016-08-17 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: assert
@@ -19,10 +19,29 @@ dependencies:
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 2.16.1
22
+ version: 2.16.3
23
23
  type: :development
24
24
  version_requirements: *id001
25
- description: Dk tasks that implement the A/B deploy pattern
25
+ - !ruby/object:Gem::Dependency
26
+ name: dk
27
+ prerelease: false
28
+ requirement: &id003 !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ~>
31
+ - *id002
32
+ type: :runtime
33
+ version_requirements: *id003
34
+ - !ruby/object:Gem::Dependency
35
+ name: much-plugin
36
+ prerelease: false
37
+ requirement: &id004 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 0.2.0
42
+ type: :runtime
43
+ version_requirements: *id004
44
+ description: Dk tasks that implement the A/B deploy scheme
26
45
  email:
27
46
  - kelly@kellyredding.com
28
47
  - collin.redding@me.com
@@ -39,10 +58,25 @@ files:
39
58
  - README.md
40
59
  - dk-abdeploy.gemspec
41
60
  - lib/dk-abdeploy.rb
61
+ - lib/dk-abdeploy/cleanup.rb
62
+ - lib/dk-abdeploy/constants.rb
63
+ - lib/dk-abdeploy/link.rb
64
+ - lib/dk-abdeploy/setup.rb
65
+ - lib/dk-abdeploy/update.rb
66
+ - lib/dk-abdeploy/utils/current_git_branch.rb
67
+ - lib/dk-abdeploy/validate.rb
42
68
  - lib/dk-abdeploy/version.rb
43
69
  - log/.gitkeep
44
70
  - test/helper.rb
45
71
  - test/support/factory.rb
72
+ - test/support/validate.rb
73
+ - test/unit/cleanup_tests.rb
74
+ - test/unit/dk-abdeploy_tests.rb
75
+ - test/unit/link_tests.rb
76
+ - test/unit/setup_tests.rb
77
+ - test/unit/update_tests.rb
78
+ - test/unit/utils/current_git_branch_tests.rb
79
+ - test/unit/validate_tests.rb
46
80
  - tmp/.gitkeep
47
81
  homepage: https://github.com/redding/dk-abdeploy
48
82
  licenses:
@@ -56,20 +90,28 @@ require_paths:
56
90
  - lib
57
91
  required_ruby_version: !ruby/object:Gem::Requirement
58
92
  requirements:
59
- - &id002
93
+ - &id005
60
94
  - ">="
61
95
  - !ruby/object:Gem::Version
62
96
  version: "0"
63
97
  required_rubygems_version: !ruby/object:Gem::Requirement
64
98
  requirements:
65
- - *id002
99
+ - *id005
66
100
  requirements: []
67
101
 
68
102
  rubyforge_project:
69
103
  rubygems_version: 2.6.4
70
104
  signing_key:
71
105
  specification_version: 4
72
- summary: Dk tasks that implement the A/B deploy pattern
106
+ summary: Dk tasks that implement the A/B deploy scheme
73
107
  test_files:
74
108
  - test/helper.rb
75
109
  - test/support/factory.rb
110
+ - test/support/validate.rb
111
+ - test/unit/cleanup_tests.rb
112
+ - test/unit/dk-abdeploy_tests.rb
113
+ - test/unit/link_tests.rb
114
+ - test/unit/setup_tests.rb
115
+ - test/unit/update_tests.rb
116
+ - test/unit/utils/current_git_branch_tests.rb
117
+ - test/unit/validate_tests.rb