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

Extend test for log-parser #1474

Merged
merged 1 commit into from
May 15, 2024

Conversation

hrubi
Copy link
Contributor

@hrubi hrubi commented May 14, 2024

I have seen several "Community Solutions" for this exercise which were not correct:

def valid_line?(line) do
line =~ ~r/^[DEBUG|INFO|WARNING|ERROR]/
end

This would yield wrong result for some lines, which are now covered by the test.

Copy link
Contributor

Thank you for contributing to exercism/elixir 💜 🎉. This is an automated PR comment 🤖 for the maintainers of this repository that helps with the PR review process. You can safely ignore it and wait for a maintainer to review your changes.

Based on the files changed in this PR, it would be good to pay attention to the following details when reviewing the PR:

  • General steps

    • 🏆 Does this PR need to receive a label with a reputation modifier (x:size/{tiny,small,medium,large,massive})? (A medium reputation amount is awarded by default, see docs)
  • Any exercise changed

    • 👤 Does the author of the PR need to be added as an author or contributor in <exercise>/.meta/config.json (see docs)?
    • 🔬 Do the analyzer and the analyzer comments exist for this exercise? Do they need to be changed?
    • 📜 Does the design file (<exercise>/.meta/design.md) need to be updated to document new implementation decisions?
  • Concept exercise changed

    • 🌲 Do prerequisites and practices in config.json need to be updated?
    • 📖 Does the concept introduction provide all necessary information to solve this exercise?
  • Concept exercise tests changed

    • ⚪️ Are all tests un-skipped?
    • 🔢 Are all tests annotated with @tag task_id?
    • 🐈 Can all tests be understood by reading the test's block only (e.g. no module attributes, no setup functions)?

Automated comment created by PR Commenter 🤖.

@angelikatyborska
Copy link
Contributor

angelikatyborska commented May 14, 2024

Thank you for pointing this out 🙏

I think adding 4 separate tests for this is a bit of an overkill, so I would prefer to extend the existing test case with a few more examples, like this:

    @tag task_id: 1
    test "level must be wrapped in square brackets" do
      assert LogParser.valid_line?("ERROR something really bad happened") == false
      assert LogParser.valid_line?("[INFO the latest information") == false
      assert LogParser.valid_line?("DEBUG] response time 3ms") == false
    end

That should be enough to catch most of those flawed community solutions, right?

I have seen several "Community Solutions" for this exercise which were
not correct:

  def valid_line?(line) do
    line =~ ~r/^\[DEBUG|INFO|WARNING|ERROR\]/
  end

This would yield wrong result for some lines, which are now covered by
the test.
@hrubi
Copy link
Contributor Author

hrubi commented May 15, 2024

I agree, thanks .

@angelikatyborska angelikatyborska merged commit 62d55ca into exercism:main May 15, 2024
10 checks passed
@angelikatyborska
Copy link
Contributor

Thanks again!

@hrubi hrubi deleted the log-parser-extend-test branch May 15, 2024 20:32
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