Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Normalize CSV Comparison in Tests to Ignore Quotes #2264

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

brunomiguelpinto
Copy link
Contributor

Description:

This PR addresses an issue with the .get_all_as_csv test in the Deprecation model where the presence of quotes around organization.name caused the test to fail. The test has been updated to normalize both the expected and actual CSV strings by removing quotes before comparison, ensuring the comparison focuses on the data content rather than the format.

@brunomiguelpinto
Copy link
Contributor Author

we can also change on the factory the name to remove the ""
name { Faker::Company.name.gsub(/[,"']/, '') } # Remove commas, double quotes, and single quotes

@brunomiguelpinto brunomiguelpinto self-assigned this Jul 8, 2024
@brunomiguelpinto
Copy link
Contributor Author

brunomiguelpinto commented Jul 8, 2024

  def csv_safe(value)
    # Enclose the value in double quotes if it contains a comma or double quote
    if value.include?(',') || value.include?('"')
      value = value.gsub('"', '""') # Escape double quotes by doubling them
      "\"#{value}\""
    else
      value
    end
  end

we can create a csv helper too

@brunomiguelpinto brunomiguelpinto merged commit 7524227 into main Jul 9, 2024
6 checks passed
@brunomiguelpinto brunomiguelpinto deleted the fix-normalize-csv-comparison branch July 9, 2024 08:50
abdussamadbello pushed a commit to abdussamadbello/lago-api that referenced this pull request Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants