Skip to content

Commit 1f04bd9

Browse files
author
Christopher Frost
committed
Pin versions in the offline buildpack
This commit fixes a broken test for the previous commit along with some formatting issues. [#93987158]
1 parent ad89969 commit 1f04bd9

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

lib/java_buildpack/util/configuration_utils.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,16 @@ def write(identifier, new_content, should_log = true)
6464
header = header(file)
6565

6666
File.open(file, 'w') do |f|
67-
header.each { |line| f.write line}
67+
header.each { |line| f.write line }
6868
# f.write(header.join('\n'))
6969
# f.write('\n')
7070
YAML.dump(new_content, f)
7171
end
7272
else
7373
logger.debug { "No configuration file #{file} found" } if should_log
7474
end
75-
7675
end
7776

78-
7977
private
8078

8179
CONFIG_DIRECTORY = Pathname.new(File.expand_path('../../../config', File.dirname(__FILE__))).freeze

spec/java_buildpack/util/configuration_utils_spec.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@
3737
end
3838

3939
it 'write configuration file' do
40-
described_class.write('test', test_data)
41-
expect(described_class.load('test')).to eq(test_data)
42-
Pathname.new(File.expand_path('../../../config/test.yml', File.dirname(__FILE__))).delete
40+
test_file = Pathname.new(File.expand_path('../../../config/tomcat.yml', File.dirname(__FILE__)))
41+
original_content = file_contents test_file
42+
loaded_content = described_class.load('tomcat')
43+
described_class.write('tomcat', loaded_content)
44+
expect(described_class.load('tomcat')).to eq(loaded_content)
45+
expect(file_contents test_file).to eq(original_content)
4346
end
4447

4548
context do
@@ -96,4 +99,16 @@
9699

97100
end
98101

102+
private
103+
104+
def file_contents(file)
105+
header = []
106+
File.open(file, 'r') do |f|
107+
f.each do |line|
108+
header << line
109+
end
110+
end
111+
header
112+
end
113+
99114
end

0 commit comments

Comments
 (0)