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

✨ Add specific error for Show-Advice #287

Merged
merged 9 commits into from
Oct 22, 2019
Merged

✨ Add specific error for Show-Advice #287

merged 9 commits into from
Oct 22, 2019

Conversation

robdy
Copy link
Contributor

@robdy robdy commented Oct 12, 2019

PR Summary

Fixes #286.

Context

As discovered in #285 and then noted in #286, Show-Advice should be more specific while erroring. I added two specific checks (if Advice was found at all and if title and content is not empty), each of them throwing specific errors. Initially I thought about having separate errors for missing title and missing content, but I think this should be handled in tests, not in the cmdlet definition (correct me if you think opposite.
As #283 (tests for *-Advice) is not yet merged, I can open an issue to have it noted, that tests should be adjusted to verify that behavior. I can wait until it's merged and then modify the tests if that's more preferred.

Changes

  • Add ObjectNotFound error for Show-Advice
  • Add InvalidData error for Show-Advice

Checklist

  • Pull Request has a meaningful title.
  • Summarised changes.
  • Pull Request is ready to merge & is not WIP.
  • Added tests / only testable interactively.
    • Make sure you add a new test if old tests do not effectively test the code changed.
  • Added documentation / opened issue to track adding documentation at a later date.

@vexx32
Copy link
Owner

vexx32 commented Oct 12, 2019

@robdy hmmm.... probably best if we sort out & merge the tests first and then you can make necessary changes to the tests in this PR, just to be safe. 💖

Copy link
Owner

@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this! 💖

Couple of minor bits and pieces I'd like to iron out, and then we'll have to get the tests merged and updated a bit here, then we're good to go! 😊

PSKoans/Public/Show-Advice.ps1 Outdated Show resolved Hide resolved
PSKoans/Public/Show-Advice.ps1 Outdated Show resolved Hide resolved
PSKoans/Public/Show-Advice.ps1 Outdated Show resolved Hide resolved
PSKoans/Public/Show-Advice.ps1 Outdated Show resolved Hide resolved
@vexx32 vexx32 added Category-Module Pertaining to the module's functionality itself. PR-Awaiting-Author ✏️ Waiting on a response from the user who submitted the PR. labels Oct 12, 2019
robdy and others added 5 commits October 14, 2019 23:31
Co-Authored-By: Joel Sallow (/u/ta11ow) <32407840+vexx32@users.noreply.github.com>
Co-Authored-By: Joel Sallow (/u/ta11ow) <32407840+vexx32@users.noreply.github.com>
Co-Authored-By: Joel Sallow (/u/ta11ow) <32407840+vexx32@users.noreply.github.com>
Co-Authored-By: Joel Sallow (/u/ta11ow) <32407840+vexx32@users.noreply.github.com>
@vexx32
Copy link
Owner

vexx32 commented Oct 22, 2019

@robdy are you still interested in working on this one? 🙂
If you need a hand with anything, just let me know!

(And if not / you're too busy, no worries, I can finish this specific issue up sometime this week and we can tackle something else later! 😊)

@robdy
Copy link
Contributor Author

robdy commented Oct 22, 2019

@vexx32 let me commit what I have today evening, I have this pretty much ready

@robdy
Copy link
Contributor Author

robdy commented Oct 22, 2019

Few comments to the recent changes. To generate incorrect files I had to adjust the existing tests. I tried to create new ones but it required loading them before. To avoid that, the test import data, modify it, perform tests and then restore the initial value.
As a result, I modified .json files so that its content is unchanged when backup is being restored.

Copy link
Owner

@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay! If it works, it works. 😊

I'm wondering whether we could possibly bypass that by Mocking Get-Content to just return the JSON string directly, for the purposes of that test? As long as you apply the Mock within the PSKoans module scope it should work... I think. (But that's me mainly guessing, so I might be overlooking something!)

Otherwise this all looks good! Thank you so much! 💖

@robdy
Copy link
Contributor Author

robdy commented Oct 22, 2019

Perhaps we can open an issue for that and I can check if I'm able to rewrite this later as you described - what do you think?

@vexx32
Copy link
Owner

vexx32 commented Oct 22, 2019

Yeah, we can roll with that. 👍

@vexx32 vexx32 merged commit 54beee2 into vexx32:master Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category-Module Pertaining to the module's functionality itself. PR-Awaiting-Author ✏️ Waiting on a response from the user who submitted the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make Show-Advice throw more specific error
2 participants