Skip to content

Commit e2ca116

Browse files
committed
Expect code 201 on success, not 200
1 parent 7158494 commit e2ca116

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_send_app_size_metrics.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def self.return_type
149149
end
150150

151151
def self.return_value
152-
'The HTTP return code from the call'
152+
'The HTTP return code from the call. Expect a 201 when new metrics were received successfully and entries created in the database'
153153
end
154154

155155
def self.authors

lib/fastlane/plugin/wpmreleasetoolkit/models/app_size_metrics_payload.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def send_metrics(base_url:, api_token:, use_gzip: true)
5656
if uri.is_a?(URI::File)
5757
UI.message("Writing metrics payload to file #{uri.path} (instead of sending it to a server)")
5858
File.write(uri.path, json_payload)
59-
return 200 # To make it easy at call site to check for pseudo-status code 200 even in non-HTTP cases
59+
return 201 # To make it easy at call site to check for pseudo-status code 200 even in non-HTTP cases
6060
end
6161

6262
UI.message("Sending metrics to #{uri}...")

spec/ios_send_app_size_metrics_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_app_size_action(fake_ipa_size:, expected_json:, **other_action_args)
2727
last_received_body = nil
2828
stub = stub_request(:post, mocked_endpoint).with(headers: expected_headers) do |req|
2929
last_received_body = req.body
30-
end.to_return(status: 200)
30+
end.to_return(status: 201)
3131

3232
# Act
3333
code = run_described_fastlane_action(
@@ -39,7 +39,7 @@ def test_app_size_action(fake_ipa_size:, expected_json:, **other_action_args)
3939

4040
# Asserts
4141
expect(stub).to have_been_made.once
42-
expect(code).to eq(200)
42+
expect(code).to eq(201)
4343
last_received_body_uncompressed = nil
4444
puts other_action_args.inspect
4545
if other_action_args[:use_gzip_content_encoding] === false
@@ -148,7 +148,7 @@ def test_app_size_action(fake_ipa_size:, expected_json:, **other_action_args)
148148
)
149149

150150
# Assert
151-
expect(code).to eq(200)
151+
expect(code).to eq(201)
152152
expect(File).to exist(output_path)
153153
expect(JSON.parse(Zlib.gunzip(File.read(output_path)))).to eq(JSON.parse(expected_json))
154154
end
@@ -178,7 +178,7 @@ def test_app_size_action(fake_ipa_size:, expected_json:, **other_action_args)
178178
)
179179

180180
# Assert
181-
expect(code).to eq(200)
181+
expect(code).to eq(201)
182182
expect(File).to exist(output_path)
183183
expect(JSON.parse(File.read(output_path))).to eq(JSON.parse(expected_json))
184184
end

0 commit comments

Comments
 (0)