Skip to content

Commit 0d3621a

Browse files
committed
Add unit tests for ios_get_app_version error cases
1 parent 690332b commit 0d3621a

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

spec/ios_get_app_version_spec.rb

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
it 'parses the xcconfig file format correctly and gets the public version' do
66
xcconfig_mock_content = <<~CONTENT
77
// a comment
8-
VERSION_SHORT=6
9-
VERSION_LONG=6.30.0
8+
VERSION_SHORT = 6
9+
VERSION_LONG = 6.30.0
1010
CONTENT
1111

1212
allow(File).to receive(:exist?).and_return(true)
@@ -16,16 +16,39 @@
1616

1717
it 'parses the xcconfig file format correctly and gets the public hotfix version' do
1818
xcconfig_mock_content = <<~CONTENT
19-
VERSION_SHORT=6
19+
VERSION_SHORT = 6
2020
// a comment
21-
VERSION_LONG=6.30.1
21+
VERSION_LONG = 6.30.1
2222
CONTENT
2323

2424
allow(File).to receive(:exist?).and_return(true)
2525

2626
expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30.1')
2727
end
2828

29+
it 'throws an error when the file is not found' do
30+
file_path = 'file/not/found'
31+
32+
expect do
33+
run_described_fastlane_action(
34+
public_version_xcconfig_file: file_path
35+
)
36+
end.to raise_error(FastlaneCore::Interface::FastlaneError)
37+
end
38+
39+
it "throws an error when there isn't a version configured in the .xcconfig file" do
40+
xcconfig_mock_content = <<~CONTENT
41+
VERSION_SHORT = 6
42+
// a comment
43+
CONTENT
44+
45+
allow(File).to receive(:exist?).and_return(true)
46+
47+
expect do
48+
expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: 'n/a')
49+
end.to raise_error(FastlaneCore::Interface::FastlaneError)
50+
end
51+
2952
def expect_version(xcconfig_mock_content:, expected_version:)
3053
xcconfig_mock_file_path = File.join('mock', 'file', 'path')
3154

0 commit comments

Comments
 (0)