Skip to content

Commit 316b7d6

Browse files
committed
Add note in an_update_metadata_source_spec to see gp_ one for docs
1 parent 14bd25b commit 316b7d6

File tree

1 file changed

+45
-15
lines changed

1 file changed

+45
-15
lines changed

spec/an_update_metadata_source_spec.rb

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
require 'spec_helper'
22

3+
# See also `gp_update_metadata_source_spec.rb` for the iOS counterpart and an
4+
# annotated spec.
5+
#
6+
# The fact that we have an Android and iOS differentiation is not ideal and
7+
# something we hope to address in an upcoming refactor/rewrite.
38
describe Fastlane::Actions::AnUpdateMetadataSourceAction do
49
it 'updates any block in a given .po file with the values from the given sources' do
510
Dir.mktmpdir do |dir|
6-
# 1: Create a dummy .po file to use as input.
711
output_path = File.join(dir, 'output.po')
812
dummy_text = <<~PO
913
msgctxt "release_note_0122"
@@ -21,36 +25,23 @@
2125
PO
2226
File.write(output_path, dummy_text)
2327

24-
# 2: Create source files with value to insert in the .po
2528
release_notes_path = File.join(dir, 'release_notes.txt')
2629
File.write(release_notes_path, "- release notes\n- more release notes")
2730
file_1_path = File.join(dir, '1.txt')
2831
File.write(file_1_path, 'value 1')
2932
file_2_path = File.join(dir, '2.txt')
3033
File.write(file_2_path, 'value 2')
31-
file_3_path = File.join(dir, '3.txt')
32-
File.write(file_3_path, 'value 3')
3334

3435
described_class.run(
3536
po_file_path: output_path,
3637
release_version: '1.23',
3738
source_files: {
3839
release_note: release_notes_path,
3940
key1: file_1_path,
40-
key2: file_2_path,
41-
key3: file_3_path # This is not in the input .po and won't be added
41+
key2: file_2_path
4242
}
4343
)
4444

45-
# 3: Assert given .po has been updated as expected
46-
#
47-
# Notice:
48-
#
49-
# - The new line after each block is added by the conversion
50-
# - That there's no new line between release_note_0122 and key1, because
51-
# the notes are copied as they are with no extra manipulation
52-
# - The key3 source is not part of the output because was not in the
53-
# original .po input
5445
expected = <<~PO
5546
msgctxt "release_note_0123"
5647
msgid ""
@@ -109,4 +100,43 @@
109100
expect(File.read(output_path)).to eq(expected)
110101
end
111102
end
103+
104+
it 'adds entries passed as input even if not part of the original `.po` file' do
105+
pending 'this currently fails and will be addressed as part of the upcoming refactor/rewrite of the functionality'
106+
Dir.mktmpdir do |dir|
107+
output_path = File.join(dir, 'output.po')
108+
dummy_text = <<~PO
109+
msgctxt "key1"
110+
msgid "this value should change"
111+
msgstr ""
112+
PO
113+
File.write(output_path, dummy_text)
114+
115+
# 2: Create source files with value to insert in the .po
116+
file_1_path = File.join(dir, '1.txt')
117+
File.write(file_1_path, 'value 1')
118+
file_2_path = File.join(dir, '2.txt')
119+
File.write(file_2_path, 'value 2')
120+
121+
described_class.run(
122+
po_file_path: output_path,
123+
source_files: {
124+
key1: file_1_path,
125+
key2: file_2_path
126+
}
127+
)
128+
129+
expected = <<~PO
130+
msgctxt "key1"
131+
msgid "value 1"
132+
msgstr ""
133+
134+
msgctxt "key2"
135+
msgid "value 2"
136+
msgstr ""
137+
138+
PO
139+
expect(File.read(output_path)).to eq(expected)
140+
end
141+
end
112142
end

0 commit comments

Comments
 (0)