This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmacro validate_schema_fields_and_types(schema, expected_schemas_and_types) do | |
| quote do | |
| test "#{unquote(schema)}: it has the correct fields and types" do | |
| schema = unquote(schema) | |
| expected_schemas_and_types = unquote(expected_schemas_and_types) | |
| actual_fields_with_types = | |
| for field <- schema.__schema__(:fields) do | |
| type = field_type(schema, field) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # option 1 - new function | |
| assert_values_for_in_list( | |
| expected_list: {[thing_1, thing_1], :string_keys}, | |
| actual_list: return_value, # is list in all the examples | |
| ordered: true, | |
| fields: fields_for(Thing) | |
| ) | |
| assert_values_for_in_list( | |
| expected_list: [thing_2, thing_1], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| assert_values_for( | |
| expected: quote_request, | |
| actual: quote, | |
| fields: fields_for(OmniWeb.Schema.QuoteRequest), | |
| field_name_translations: [ | |
| # explicit | |
| origin_postal_code: [actual: :origin_zip], | |
| destination_postal_code: [expected: :destination_zip, actual: :destination_zipcode], | |
| # implicit | |
| pieces: :freight_pieces, # assumes field is from expected and that this is on actual? |
OlderNewer