|
14 | 14 |
|
15 | 15 | it { is_expected.to have_many(:flow_settings) }
|
16 | 16 | end
|
| 17 | + |
| 18 | + describe '#to_grpc' do |
| 19 | + let(:flow) do |
| 20 | + create(:flow, |
| 21 | + flow_settings: [ |
| 22 | + create(:flow_setting, |
| 23 | + flow_setting_id: 'example_key', |
| 24 | + object: { some_key: 'some_value' }) |
| 25 | + ], |
| 26 | + starting_node: create(:node_function, |
| 27 | + node_parameters: [ |
| 28 | + create(:node_parameter, |
| 29 | + runtime_parameter: create(:runtime_parameter_definition, |
| 30 | + data_type: create(:data_type_identifier, |
| 31 | + generic_key: 'T'))) |
| 32 | + ])) |
| 33 | + end |
| 34 | + |
| 35 | + it 'matches the model' do |
| 36 | + grpc_object = flow.to_grpc |
| 37 | + |
| 38 | + expect(grpc_object.to_h).to eq({ |
| 39 | + data_types: [], |
| 40 | + flow_id: flow.id, |
| 41 | + project_id: flow.project.id, |
| 42 | + type: flow.flow_type.identifier, |
| 43 | + input_type_identifier: flow.input_type&.identifier || '', |
| 44 | + return_type_identifier: flow.return_type&.identifier || '', |
| 45 | + starting_node: { |
| 46 | + database_id: flow.starting_node.id, |
| 47 | + next_node: nil, |
| 48 | + runtime_function_id: flow.starting_node.runtime_function.runtime_name, |
| 49 | + parameters: [ |
| 50 | + { |
| 51 | + database_id: flow.starting_node.node_parameters.first.id, |
| 52 | + runtime_parameter_id: |
| 53 | + flow.starting_node.node_parameters.first.runtime_parameter.runtime_name, |
| 54 | + function_value: nil, |
| 55 | + literal_value: { |
| 56 | + bool_value: false, |
| 57 | + list_value: nil, |
| 58 | + null_value: :NULL_VALUE, |
| 59 | + number_value: 0.0, |
| 60 | + string_value: flow.starting_node.node_parameters.first.literal_value, |
| 61 | + struct_value: nil, |
| 62 | + }, |
| 63 | + reference_value: nil, |
| 64 | + } |
| 65 | + ], |
| 66 | + }, |
| 67 | + settings: [ |
| 68 | + database_id: flow.flow_settings.first.id, |
| 69 | + flow_setting_id: flow.flow_settings.first.flow_setting_id, |
| 70 | + object: { |
| 71 | + fields: { |
| 72 | + 'some_key' => { |
| 73 | + bool_value: false, |
| 74 | + list_value: nil, |
| 75 | + null_value: :NULL_VALUE, |
| 76 | + number_value: 0.0, |
| 77 | + string_value: flow.flow_settings.first.object['some_key'], |
| 78 | + struct_value: nil, |
| 79 | + }, |
| 80 | + }, |
| 81 | + } |
| 82 | + ], |
| 83 | + }) |
| 84 | + end |
| 85 | + end |
17 | 86 | end
|
0 commit comments