falkorlib 0.6.18 → 0.6.19
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 +4 -4
- data/Gemfile.lock +17 -2
- data/falkorlib.gemspec +1 -1
- data/lib/falkorlib/tasks/rspec.rake +5 -4
- data/lib/falkorlib/version.rb +1 -1
- data/spec/falkorlib/bootstrap_helpers_spec.rb +10 -10
- data/spec/falkorlib/bootstrap_spec.rb +21 -21
- data/spec/falkorlib/common_spec.rb +45 -45
- data/spec/falkorlib/config_spec.rb +5 -5
- data/spec/falkorlib/error_spec.rb +1 -1
- data/spec/falkorlib/git_spec.rb +43 -43
- data/spec/falkorlib/gitflow_spec.rb +13 -13
- data/spec/falkorlib/puppet_modules_spec.rb +166 -166
- data/spec/falkorlib/versioning_gem_spec.rb +22 -22
- data/spec/falkorlib/versioning_puppet_module_spec.rb +11 -11
- data/spec/falkorlib/versioning_spec.rb +86 -86
- data/spec/falkorlib_spec.rb +1 -1
- metadata +15 -1
@@ -13,7 +13,7 @@ describe FalkorLib::Config do
|
|
13
13
|
:key => 'val'
|
14
14
|
}
|
15
15
|
}
|
16
|
-
|
16
|
+
|
17
17
|
after :all do
|
18
18
|
FileUtils.remove_entry_secure dir
|
19
19
|
end
|
@@ -24,19 +24,19 @@ describe FalkorLib::Config do
|
|
24
24
|
it "#default" do
|
25
25
|
hash = FalkorLib::Config.default
|
26
26
|
t = hash.is_a? Hash
|
27
|
-
t.
|
28
|
-
hash[:rvm][:versionfile].
|
27
|
+
expect(t).to be true
|
28
|
+
expect(hash[:rvm][:versionfile]).to eq(FalkorLib::Config::DEFAULTS[:rvm][:versionfile])
|
29
29
|
end
|
30
30
|
|
31
31
|
it "#save" do
|
32
32
|
FalkorLib::Config.save(dir, test_hash, :local, { :no_interaction => true })
|
33
33
|
t = File.exists?( File.join(dir, FalkorLib::Config::DEFAULTS[:config_files][:local]))
|
34
|
-
t.
|
34
|
+
expect(t). to be true
|
35
35
|
end
|
36
36
|
|
37
37
|
it "#get" do
|
38
38
|
h = FalkorLib::Config.get(dir, :local, { :no_interaction => true })
|
39
|
-
h.
|
39
|
+
expect(h).to eq(test_hash)
|
40
40
|
end
|
41
41
|
|
42
42
|
end
|
data/spec/falkorlib/git_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#########################################
|
3
3
|
# git_spec.rb
|
4
4
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
-
# Time-stamp: <
|
5
|
+
# Time-stamp: <Sun 2016-10-16 22:05 svarrette>
|
6
6
|
#
|
7
7
|
# @description Check the Git operations
|
8
8
|
#
|
@@ -34,19 +34,19 @@ describe FalkorLib::Git do
|
|
34
34
|
|
35
35
|
it "#init? - fails on non-git directory" do
|
36
36
|
t = FalkorLib::Git.init?(dir)
|
37
|
-
t.
|
37
|
+
expect(t).to be false
|
38
38
|
end
|
39
39
|
|
40
40
|
it "#init - initialize a git repository" do
|
41
41
|
c = FalkorLib::Git.init(dir)
|
42
|
-
c.
|
42
|
+
expect(c).to eq(0)
|
43
43
|
t = FalkorLib::Git.init?(dir)
|
44
|
-
t.
|
44
|
+
expect(t).to be true
|
45
45
|
end
|
46
46
|
|
47
47
|
it "#remotes? -- should be false" do
|
48
48
|
t = FalkorLib::Git.remotes?(dir)
|
49
|
-
t.
|
49
|
+
expect(t).to be false
|
50
50
|
end
|
51
51
|
|
52
52
|
it "#rootdir #gitdir - checks git dir and working tree" do
|
@@ -55,59 +55,59 @@ describe FalkorLib::Git do
|
|
55
55
|
Dir.chdir( subdir ) do
|
56
56
|
r = File.realpath( FalkorLib::Git.rootdir )
|
57
57
|
g = FalkorLib::Git.gitdir
|
58
|
-
r.
|
59
|
-
g.
|
58
|
+
expect(r).to eq(File.realpath(dir))
|
59
|
+
expect(g).to eq(File.realpath( File.join(dir, '.git') ))
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
it "#has_commits? - not yet any commits" do
|
64
64
|
b = FalkorLib::Git.has_commits?( dir )
|
65
|
-
b.
|
65
|
+
expect(b).to be false
|
66
66
|
end
|
67
67
|
|
68
68
|
it "#branch? - check non-existing branch" do
|
69
69
|
br = FalkorLib::Git.branch?( dir )
|
70
|
-
br.
|
70
|
+
expect(br).to be_nil
|
71
71
|
end
|
72
72
|
|
73
73
|
it "#list_files -- should not list any files" do
|
74
74
|
l = FalkorLib::Git.list_files( dir )
|
75
|
-
l.
|
75
|
+
expect(l).to be_empty
|
76
76
|
end
|
77
77
|
|
78
78
|
it "#add - makes a first commit" do
|
79
79
|
FileUtils.touch( afile )
|
80
80
|
t = FalkorLib::Git.add(afile)
|
81
|
-
t.
|
81
|
+
expect(t).to eq(0)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "#list_files -- should list a single files" do
|
85
85
|
l = FalkorLib::Git.list_files( dir )
|
86
|
-
l.
|
86
|
+
expect(l).to include 'a_file'
|
87
87
|
end
|
88
88
|
|
89
89
|
|
90
90
|
it "#has_commits? - no some commits have been done" do
|
91
91
|
b = FalkorLib::Git.has_commits?( dir )
|
92
|
-
b.
|
92
|
+
expect(b).to be true
|
93
93
|
end
|
94
94
|
|
95
95
|
|
96
96
|
it "#branch? - check existing branch" do
|
97
97
|
br = FalkorLib::Git.branch?( dir )
|
98
|
-
br.
|
98
|
+
expect(br).to eq('master')
|
99
99
|
end
|
100
100
|
|
101
101
|
it "#dirty? - check non-dirty git directory" do
|
102
102
|
b = FalkorLib::Git.dirty?( dir )
|
103
|
-
b.
|
103
|
+
expect(b).to be false
|
104
104
|
end
|
105
105
|
|
106
106
|
default_branches.each do |br|
|
107
107
|
it "#create_branch #list_branch - creates branch #{br}" do
|
108
108
|
FalkorLib::Git.create_branch( br, dir )
|
109
109
|
l = FalkorLib::Git.list_branch( dir )
|
110
|
-
l.
|
110
|
+
expect(l).to include "#{br}"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -115,70 +115,70 @@ describe FalkorLib::Git do
|
|
115
115
|
it "#delete_branch #list_branch - deletes branch #{br}" do
|
116
116
|
FalkorLib::Git.delete_branch( br, dir) #, :force => true )
|
117
117
|
l = FalkorLib::Git.list_branch( dir )
|
118
|
-
l.
|
118
|
+
expect(l).not_to include "#{br}"
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
it "#command? - check non-availability of git command 'toto'" do
|
123
123
|
c = FalkorLib::Git.command?('toto')
|
124
|
-
c.
|
124
|
+
expect(c).to be false
|
125
125
|
end
|
126
126
|
|
127
127
|
it "#command? - check availability of git command 'init'" do
|
128
128
|
c = FalkorLib::Git.command?('init')
|
129
|
-
c.
|
129
|
+
expect(c).to be true
|
130
130
|
end
|
131
131
|
|
132
132
|
it "#config -- check existing key" do
|
133
133
|
c = FalkorLib::Git.config('user.name', dir)
|
134
|
-
c.
|
134
|
+
expect(c).not_to be_empty
|
135
135
|
t = c.is_a? String
|
136
|
-
t.
|
136
|
+
expect(t).to be true
|
137
137
|
end
|
138
138
|
|
139
139
|
it "#config -- check non-existing key" do
|
140
140
|
c = FalkorLib::Git.config('user.nam', dir)
|
141
|
-
c.
|
141
|
+
expect(c).to be_nil
|
142
142
|
end
|
143
143
|
|
144
144
|
it "#config -- check all keys" do
|
145
145
|
c = FalkorLib::Git.config('*', dir)
|
146
|
-
c.
|
146
|
+
expect(c).not_to be_empty
|
147
147
|
t = c.is_a? Array
|
148
|
-
t.
|
148
|
+
expect(t).to be true
|
149
149
|
end
|
150
150
|
|
151
151
|
it "#config -- check pattern" do
|
152
152
|
c = FalkorLib::Git.config('user*', dir)
|
153
|
-
c.
|
153
|
+
expect(c).not_to be_empty
|
154
154
|
t = c.is_a? Array
|
155
|
-
t.
|
155
|
+
expect(t).to be true
|
156
156
|
ap c
|
157
|
-
c.length.
|
157
|
+
expect(c.length).to be >= 2
|
158
158
|
end
|
159
159
|
|
160
160
|
it "#config -- check pattern 2" do
|
161
161
|
c = FalkorLib::Git.config(/.*name=/, dir)
|
162
|
-
c.
|
162
|
+
expect(c).not_to be_empty
|
163
163
|
t = c.is_a? Array
|
164
|
-
t.
|
165
|
-
c.length.
|
164
|
+
expect(t).to be true
|
165
|
+
expect(c.length).to eq(1)
|
166
166
|
end
|
167
167
|
|
168
168
|
it "#config -- return hash" do
|
169
169
|
c = FalkorLib::Git.config('user*', dir, :hash => true)
|
170
|
-
c.
|
170
|
+
expect(c).not_to be_empty
|
171
171
|
t = c.is_a? Hash
|
172
|
-
t.
|
172
|
+
expect(t).to be true
|
173
173
|
ap c
|
174
|
-
c.keys.length.
|
174
|
+
expect(c.keys.length).to be >= 2
|
175
175
|
end
|
176
176
|
|
177
177
|
it "#config -- check hash correctness" do
|
178
178
|
key = 'user.name'
|
179
179
|
c = FalkorLib::Git.config('user*', dir, :hash => true)
|
180
180
|
n = FalkorLib::Git.config('user.name', dir)
|
181
|
-
n.
|
181
|
+
expect(n).to eq(c[ key ])
|
182
182
|
end
|
183
183
|
|
184
184
|
# ---------- Submodules ---------------
|
@@ -192,17 +192,17 @@ describe FalkorLib::Git do
|
|
192
192
|
}
|
193
193
|
end
|
194
194
|
b = FalkorLib::Git.submodule_init( dir )
|
195
|
-
b.
|
195
|
+
expect(b).to eq(0)
|
196
196
|
end
|
197
197
|
|
198
198
|
it "#submodules_update" do
|
199
199
|
b = FalkorLib::Git.submodule_update( dir )
|
200
|
-
b.
|
200
|
+
expect(b).to eq(0)
|
201
201
|
end
|
202
202
|
|
203
203
|
it "#submodules_upgrade" do
|
204
204
|
b = FalkorLib::Git.submodule_upgrade( dir )
|
205
|
-
b.
|
205
|
+
expect(b).to eq(0)
|
206
206
|
end
|
207
207
|
|
208
208
|
# ---------- Subtrees ---------------
|
@@ -218,28 +218,28 @@ describe FalkorLib::Git do
|
|
218
218
|
|
219
219
|
it "#subtree_init? -- should check that the subtree(s) have not been initialized" do
|
220
220
|
b = FalkorLib::Git.subtree_init?( dir )
|
221
|
-
b.
|
221
|
+
expect(b).to be false
|
222
222
|
end
|
223
223
|
|
224
224
|
it "#subtree_init - initialize some Git Subtrees" do
|
225
225
|
|
226
226
|
b = FalkorLib::Git.subtree_init( dir )
|
227
|
-
b.
|
227
|
+
expect(b).to eq(0)
|
228
228
|
end
|
229
229
|
|
230
230
|
it "#subtree_init? -- should check that the subtree(s) have been initialized" do
|
231
231
|
b = FalkorLib::Git.subtree_init?( dir )
|
232
|
-
b.
|
232
|
+
expect(b).to be true
|
233
233
|
end
|
234
234
|
|
235
235
|
it "#subtree_up" do
|
236
236
|
b = FalkorLib::Git.subtree_up( dir )
|
237
|
-
b.
|
237
|
+
expect(b).to eq(0)
|
238
238
|
end
|
239
239
|
|
240
240
|
it "#subtree_diff" do
|
241
241
|
b = FalkorLib::Git.subtree_diff( dir )
|
242
|
-
b.
|
242
|
+
expect(b).to eq(0)
|
243
243
|
puts FalkorLib::Git.dirty?( dir )
|
244
244
|
end
|
245
245
|
end
|
@@ -251,7 +251,7 @@ describe FalkorLib::Git do
|
|
251
251
|
it "#dirty? - check dirty git directory" do
|
252
252
|
execute "echo 'toto' > #{afile}"
|
253
253
|
b = FalkorLib::Git.dirty?( dir )
|
254
|
-
b.
|
254
|
+
expect(b).to be true
|
255
255
|
end
|
256
256
|
|
257
257
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#########################################
|
3
3
|
# gitflow_spec.rb
|
4
4
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
-
# Time-stamp: <
|
5
|
+
# Time-stamp: <Sun 2016-10-16 22:06 svarrette>
|
6
6
|
#
|
7
7
|
# @description Check the Git Flow operations -- see https://github.com/nvie/gitflow
|
8
8
|
#
|
@@ -31,38 +31,38 @@ describe FalkorLib::GitFlow do
|
|
31
31
|
|
32
32
|
it "#init? - fails on non-git directory" do
|
33
33
|
t = FalkorLib::GitFlow.init?(dir)
|
34
|
-
t.
|
35
|
-
end
|
34
|
+
expect(t).to be false
|
35
|
+
end
|
36
36
|
|
37
37
|
it "#init - initialize a git-flow repository" do
|
38
|
-
STDIN.
|
38
|
+
expect(STDIN).to receive(:gets).and_return('Yes')
|
39
39
|
i = FalkorLib::GitFlow.init(dir)
|
40
|
-
i.
|
40
|
+
expect(i).to eq(0)
|
41
41
|
t = FalkorLib::Git.init?(dir)
|
42
|
-
t.
|
42
|
+
expect(t).to be true
|
43
43
|
end
|
44
44
|
|
45
45
|
it "#init? - succeed on git-flow enabled directory" do
|
46
46
|
t = FalkorLib::GitFlow.init?(dir)
|
47
|
-
t.
|
48
|
-
end
|
47
|
+
expect(t).to be true
|
48
|
+
end
|
49
49
|
|
50
50
|
#['feature', 'hotfix', 'support'].each do |op|
|
51
51
|
['feature'].each do |op|
|
52
52
|
name = 'toto'
|
53
53
|
it "#start -- should start a '#{op}' GitFlow operation" do
|
54
54
|
a = FalkorLib::GitFlow.start(op, name, dir)
|
55
|
-
a.
|
55
|
+
expect(a).to eq(0)
|
56
56
|
br = FalkorLib::Git.branch?( dir )
|
57
|
-
br.
|
57
|
+
expect(br).to eq("#{op}/#{name}")
|
58
58
|
end
|
59
59
|
|
60
60
|
it "#finish -- should finish a '#{op}' GitFlow operation" do
|
61
|
-
STDIN.
|
61
|
+
expect(STDIN).to receive(:gets).and_return("Test #{op} operation") if [ 'hotfix', 'support' ].include?(op)
|
62
62
|
a = FalkorLib::GitFlow.finish(op, name, dir)
|
63
|
-
a.
|
63
|
+
expect(a).to eq(0)
|
64
64
|
br = FalkorLib::Git.branch?( dir )
|
65
|
-
br.
|
65
|
+
expect(br).to eq(FalkorLib.config[:gitflow][:branches][:develop])
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#########################################
|
3
3
|
# puppet_modules_spec.rb
|
4
4
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
-
# Time-stamp: <
|
5
|
+
# Time-stamp: <Sun 2016-10-16 22:06 svarrette>
|
6
6
|
#
|
7
7
|
# @description Check the Puppet Modules operations
|
8
8
|
#
|
@@ -16,172 +16,172 @@ require 'falkorlib/puppet'
|
|
16
16
|
require 'json'
|
17
17
|
|
18
18
|
describe FalkorLib::Puppet::Modules do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
include FalkorLib::Common
|
20
|
+
|
21
|
+
dir = Dir.mktmpdir
|
22
|
+
# Module name
|
23
|
+
name = 'toto'
|
24
|
+
moduledir = File.join(dir, name)
|
25
|
+
jsonfile = File.join( moduledir, 'metadata.json')
|
26
|
+
|
27
|
+
#afile = File.join(dir, 'a_file')
|
28
|
+
# before :all do
|
29
|
+
# ENV['GIT_AUTHOR_NAME'] = 'travis' if ENV['GIT_AUTHOR_NAME'].nil?
|
30
|
+
# ENV['GIT_AUTHOR_EMAIL'] = 'travis@domain.org' if ENV['GIT_AUTHOR_EMAIL'].nil?
|
31
|
+
# end
|
32
|
+
|
33
|
+
after :all do
|
34
|
+
FileUtils.remove_entry_secure dir
|
35
|
+
end
|
36
|
+
|
37
|
+
#############################################################
|
38
|
+
context "Test Puppet Module creation within temporary directory " do
|
39
|
+
|
40
|
+
|
41
|
+
it "#init -- create a puppet module" do
|
42
|
+
# Prepare answer to the questions
|
43
|
+
Array.new(17).each { |e| expect(STDIN).to receive(:gets).and_return('') }
|
44
|
+
FalkorLib::Puppet::Modules.init(moduledir)
|
45
|
+
templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
|
46
|
+
s = true
|
47
|
+
puts "templatedir = #{templatedir}"
|
48
|
+
Dir["#{templatedir}/**/*"].each do |e|
|
49
|
+
next if File.directory?(e)
|
50
|
+
relative_dir = Pathname.new( File.realpath( File.dirname(e) )).relative_path_from Pathname.new(templatedir)
|
51
|
+
file = e.gsub(/templatename/, "#{name}")
|
52
|
+
filename = File.basename(file)
|
53
|
+
filename = File.basename(file, '.erb') unless file =~ /templates\/toto-variables\.erb/
|
54
|
+
f = File.join(moduledir, relative_dir, filename)
|
55
|
+
puts "checking #{f} - #{File.exists?( f )}"
|
56
|
+
s &= File.exists?( f )
|
57
|
+
end
|
58
|
+
expect(s).to be true
|
35
59
|
end
|
36
60
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
})
|
163
|
-
d.should == 0
|
164
|
-
end
|
165
|
-
|
166
|
-
it "#upgrade -- exclude some files" do
|
167
|
-
d = FalkorLib::Puppet::Modules.upgrade(moduledir, {
|
168
|
-
:no_interaction => true,
|
169
|
-
:exclude => [ 'README.md']
|
170
|
-
})
|
171
|
-
d.should == 0
|
172
|
-
#d.should == (upgraded_files_default - 1)
|
173
|
-
end
|
174
|
-
|
175
|
-
it "#upgrade -- both include and exclude files" do
|
176
|
-
d = FalkorLib::Puppet::Modules.upgrade(moduledir, {
|
177
|
-
:no_interaction => true,
|
178
|
-
:only => [ 'README.md'],
|
179
|
-
:exclude => [ 'README.md']
|
180
|
-
})
|
181
|
-
d.should == 0
|
182
|
-
end
|
183
|
-
|
184
|
-
|
185
|
-
end # context
|
61
|
+
it "#_getclassdefs -- should failed on unrecogized type" do
|
62
|
+
expect { FalkorLib::Puppet::Modules._get_classdefs(dir, 'toto') }.to raise_error (SystemExit)
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
it "#classes -- list classes" do
|
67
|
+
l = FalkorLib::Puppet::Modules._get_classdefs(moduledir, 'classes')
|
68
|
+
c = FalkorLib::Puppet::Modules.classes(moduledir)
|
69
|
+
expect(c).to eq(l)
|
70
|
+
ref = [
|
71
|
+
"toto::params",
|
72
|
+
"toto",
|
73
|
+
"toto::common",
|
74
|
+
"toto::common::debian",
|
75
|
+
"toto::common::redhat"
|
76
|
+
]
|
77
|
+
expect(c.size).to eq(ref.size)
|
78
|
+
c.each { |e| expect(ref).to include(e) }
|
79
|
+
end
|
80
|
+
|
81
|
+
it "#definitions -- list definitions" do
|
82
|
+
d = FalkorLib::Puppet::Modules.definitions(moduledir)
|
83
|
+
expect(d).to eq([ "toto::mydef" ])
|
84
|
+
end
|
85
|
+
|
86
|
+
it "#deps -- list dependencies" do
|
87
|
+
d = FalkorLib::Puppet::Modules.deps(moduledir)
|
88
|
+
expect(d).to eq([])
|
89
|
+
end
|
90
|
+
|
91
|
+
it "#metadata" do
|
92
|
+
ref = JSON.parse( IO.read( jsonfile ) )
|
93
|
+
metadata = FalkorLib::Puppet::Modules.metadata(moduledir, {
|
94
|
+
:use_symbols => false,
|
95
|
+
:extras => false
|
96
|
+
})
|
97
|
+
ref.keys.each do |k|
|
98
|
+
expect(metadata[k]).to eq(ref[k])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
it "#parse" do
|
104
|
+
#STDIN.should_receive(:gets).and_return('')
|
105
|
+
ref = JSON.parse( IO.read( jsonfile ) )
|
106
|
+
metadata = FalkorLib::Puppet::Modules.parse(moduledir, { :no_interaction => true })
|
107
|
+
diff = (metadata.to_a - ref.to_a).flatten.sort
|
108
|
+
expect(diff).to eq([
|
109
|
+
'classes',
|
110
|
+
'definitions',
|
111
|
+
'toto',
|
112
|
+
'toto::common',
|
113
|
+
'toto::common::debian',
|
114
|
+
'toto::common::redhat',
|
115
|
+
'toto::mydef',
|
116
|
+
'toto::params',
|
117
|
+
])
|
118
|
+
end
|
119
|
+
|
120
|
+
it "#parse again -- should not exhibit any difference" do
|
121
|
+
ref = JSON.parse( IO.read( jsonfile ) )
|
122
|
+
metadata = FalkorLib::Puppet::Modules.parse(moduledir, { :no_interaction => true })
|
123
|
+
diff = (metadata.to_a - ref.to_a).flatten.sort
|
124
|
+
expect(diff).to eq([])
|
125
|
+
end
|
126
|
+
|
127
|
+
it "#deps -- should find a new dependency" do
|
128
|
+
classfile = File.join(moduledir, 'manifests', 'init.pp')
|
129
|
+
newdep = "tata"
|
130
|
+
run %{ echo 'include "#{newdep}"' >> #{classfile} }
|
131
|
+
a = FalkorLib::Puppet::Modules.deps(moduledir)
|
132
|
+
expect(a).to include newdep
|
133
|
+
end
|
134
|
+
|
135
|
+
it "#parse again -- should ask new dependency elements" do
|
136
|
+
ref = JSON.parse( IO.read( jsonfile ) )
|
137
|
+
expect(STDIN).to receive(:gets).and_return('svarrette')
|
138
|
+
expect(STDIN).to receive(:gets).and_return('1.2')
|
139
|
+
expect(STDIN).to receive(:gets).and_return('Yes')
|
140
|
+
expect(STDIN).to receive(:gets).and_return('')
|
141
|
+
metadata = FalkorLib::Puppet::Modules.parse(moduledir)
|
142
|
+
diff = (metadata.to_a - ref.to_a).flatten
|
143
|
+
expect(diff).to eq([
|
144
|
+
'dependencies',
|
145
|
+
{"name"=>"puppetlabs-stdlib", "version_requirement"=>">=4.2.2 <5.0.0"},
|
146
|
+
{"name"=>"svarrette/tata", "version_requirement"=>"1.2"}
|
147
|
+
])
|
148
|
+
end
|
149
|
+
|
150
|
+
upgraded_files_default = 1
|
151
|
+
it "#upgrade" do
|
152
|
+
d = FalkorLib::Puppet::Modules.upgrade(moduledir, {
|
153
|
+
:no_interaction => true
|
154
|
+
})
|
155
|
+
expect(d).to eq(upgraded_files_default)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "#upgrade -- with only a subset of files" do
|
159
|
+
d = FalkorLib::Puppet::Modules.upgrade(moduledir, {
|
160
|
+
:no_interaction => true,
|
161
|
+
:only => [ 'README.md', 'Gemfile']
|
162
|
+
})
|
163
|
+
expect(d).to eq(0)
|
164
|
+
end
|
165
|
+
|
166
|
+
it "#upgrade -- exclude some files" do
|
167
|
+
d = FalkorLib::Puppet::Modules.upgrade(moduledir, {
|
168
|
+
:no_interaction => true,
|
169
|
+
:exclude => [ 'README.md']
|
170
|
+
})
|
171
|
+
expect(d).to eq(0)
|
172
|
+
#d.should == (upgraded_files_default - 1)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "#upgrade -- both include and exclude files" do
|
176
|
+
d = FalkorLib::Puppet::Modules.upgrade(moduledir, {
|
177
|
+
:no_interaction => true,
|
178
|
+
:only => [ 'README.md'],
|
179
|
+
:exclude => [ 'README.md']
|
180
|
+
})
|
181
|
+
expect(d).to eq(0)
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
end # context
|
186
186
|
|
187
187
|
end
|