Skip to content

Commit 4667938

Browse files
committed
update enum list deserialization
1 parent 50b1aac commit 4667938

File tree

3 files changed

+40
-67
lines changed

3 files changed

+40
-67
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"data": {
3+
"type": "downtime",
4+
"attributes": {
5+
"mute_first_recovery_notification": false,
6+
"schedule": {
7+
"end": null,
8+
"start": "2024-11-10T03:12:35.223223+00:00"
9+
},
10+
"notify_end_types": [
11+
"expired"
12+
],
13+
"status": "active",
14+
"monitor_identifier": {
15+
"monitor_tags": [
16+
"*"
17+
]
18+
},
19+
"display_timezone": "UTC",
20+
"notify_end_states": [
21+
"warn",
22+
"alert",
23+
"not an end state"
24+
],
25+
"created": "2024-11-10T03:12:35.241213+00:00",
26+
"modified": "2024-11-10T03:12:35.241213+00:00",
27+
"canceled": null,
28+
"message": null,
29+
"scope": "host:java-hostsMuteErrorsTest-local-1731208355"
30+
},
31+
"id": "a5546ef7-fea3-4a1b-b82e-04f8067f655a"
32+
}
33+
}

spec/fixtures/synthetics_unknown_nested_enum_in_list.json

Lines changed: 0 additions & 59 deletions
This file was deleted.

spec/v1/deserialization_spec.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@
3737
end
3838

3939
it 'should deserialize unknown nested enum in list' do
40-
fixture = File.read('spec/fixtures/synthetics_unknown_nested_enum_in_list.json')
41-
stub_request(:get, "#{@base_path}api/v1/synthetics/tests/api/public_id")
40+
fixture = File.read('spec/fixtures/downtimes_unknown_nested_enum_in_list.json')
41+
stub_request(:get, "#{@base_path}api/v2/downtime/downtime_id")
4242
.to_return(:body => fixture, :headers => [{"Content-Type": "application/json"}], :status => 299)
43+
data = DatadogAPIClient::V2::DowntimesAPI.new.get_downtime("downtime_id")
4344

44-
data = @api_instance.get_api_test("public_id")
45-
46-
expect(data).to be_a DatadogAPIClient::V1::SyntheticsAPITest
47-
expect(data.options.device_ids.length).to be 3
48-
expect(data.options._unparsed).to be true
49-
expect(data.options.device_ids[2].to_hash).to eq DatadogAPIClient::V1::SyntheticsDeviceID.build_from_hash("A non existent device ID").to_hash
45+
expect(data).to be_a DatadogAPIClient::V2::DowntimeResponse
46+
expect(data.data.attributes.notify_end_states.length).to be 3
47+
expect(data.data.attributes._unparsed).to be true
48+
expect(data.data.attributes.notify_end_states[2].to_hash).to eq DatadogAPIClient::V2::DowntimeNotifyEndStateTypes.build_from_hash("not an end state").to_hash
5049
end
5150

5251
it 'should deserialize unknown top level enum' do

0 commit comments

Comments
 (0)