(GH-14) Adding additional IconUrl check#23
(GH-14) Adding additional IconUrl check#23gep13 wants to merge 2 commits intochocolatey-archive:masterfrom
Conversation
There was a problem hiding this comment.
This could be null, so it may be helpful to return if the package.IconUrl is empty
|
Fix up the checks a bit so there are no null reference exceptions. |
|
@ferventcoder ah, good shout! I think I have corrected the logic flow. Let me know if you spot any other problems. |
|
Always resubmit the same commits unless the new changes add something additional. A code review is not one of them. (same comments for full effect ;) ) |
There was a problem hiding this comment.
We have a failure already accounted for projectUrl being empty, but I think it is okay to do this here. 👍
There was a problem hiding this comment.
Agreed, this is a side effect of this specific test, and also a slight duplication of the other test, is it actually testing something else.
ce02888 to
e070513
Compare
|
@ferventcoder just away to head for the night, but will follow up with any comments in the morning. Let me know what you think. |
There was a problem hiding this comment.
If there was ever a valid reason for adding tests, this is one.
There was a problem hiding this comment.
yeah, I was actually thinking that as I was creating it. :-D Have you got an example of how you would like the test harness, etc, set up, adn i can take a stab at it?
There was a problem hiding this comment.
There is a tests project. I'm taking it that there are no examples yet though?
There was a problem hiding this comment.
The testing harness would be similar to choco's
There was a problem hiding this comment.
I don't "think" there are, but ill admit, I only glanced. Will take a look, and see what I can come up with.
Would you see the get_domain_from_host method staying within the rule, or moved out into own class? Made static? Or create interface and constructor inject?
Just throwing ideas out just now. Not at computer now, so will be at least tomorrow.
There was a problem hiding this comment.
Make it a public method and then test it there.
|
@ferventcoder as a start (work still required) is the second commit the type of thing that you had in mind? |
|
NOTE: Never used TinySpec before, so very much feeling my way around here, but used some examples from choco in order to create this. |
There was a problem hiding this comment.
This is a great start! You could probably change the because to empty and then do this in all of the tests:
iconGuideline.get_domain_from_host("www.test.com").ShouldEqual("test.com")
And then add tests for the following scenarios:
- test.com
- www.test.com
- somewildsubdomain.test.com
There was a problem hiding this comment.
so, is each of those a separate test, or rather Fact? In other testing frameworks I have used/seen you can overload the test with multiple input and expected values, and it runs through the single test of each theory. Does that work here, or should I create three separate facts? If so, any suggestions as the the name of each fact?
There was a problem hiding this comment.
It's using nunit in the background, so you could add that logic, I just prefer separate specs for each so the names are specific to what failed - unless you have a way of changing the test name based on the input.
There was a problem hiding this comment.
It's really working with testing for so long - I should know from the name of the test alone exactly what failed before I go to dig into how to fix it. If I have to dig into the test itself to find out why it is failing then something is wrong. That's the theory anyway. It works out most of the time.
|
@ferventcoder ok, let me know what you think. |
There was a problem hiding this comment.
I would not have thought of this scenario, but that appears to be valid. :)
There was a problem hiding this comment.
Can you add one more scenario for me?
subdomain.tla.com
|
@ferventcoder ok, so that scenario results in a failed tests, which is what I think you thought would happen :-) I will look at the regex, and see if there is anything that can be done. |
|
@ferventcoder I have added that scenario though, and pushed to this PR. |
You caught me :D |
|
@ferventcoder what do you think of this change? |
There was a problem hiding this comment.
is this the only domain like this?
There was a problem hiding this comment.
There was a problem hiding this comment.
There was a problem hiding this comment.
There was a problem hiding this comment.
No, I didn't think it was, but I also didn't know of a clever way to encompass all the edge cases :-(
There was a problem hiding this comment.
It's possible we just call this good enough.
There was a problem hiding this comment.
I have one more approach that I want to try out, going to give it a whack at lunch time. If I don't get anywhere, I will fallback to what we have.
|
@ferventcoder what do you think about this alternative approach? |
There was a problem hiding this comment.
Just noticed this. You don't need to call context. It is done automatically for you.
There was a problem hiding this comment.
Oh really? I am fairly sure I saw this in some of the Chocolatey Tests, so I just copied it from there. But I will take this out, and give it a try. Cheers!
There was a problem hiding this comment.
Ooooh. Yeah it was likely each of them was calling a reset to remove state.
"Under this context (arrange), because this happened (act), it should result in (assert)..."
Usually you set everything up in context, then because is the action (or the SUT), then all of the facts are just assertions. Sometimes you want to short circuit that because you have many, many scenarios that require little setup. I tend to prefer less ceremony because each arrange and act is usually an entire class with multiple assertions on that one action.
There was a problem hiding this comment.
Gotcha, that makes sense now then.
I had been looking at this:
But this fits with exactly what you are describing.
There was a problem hiding this comment.
Yes, that is one that is definitely a smaller setup. Would be a ton of spec classes for little benefit.
There was a problem hiding this comment.
There was a problem hiding this comment.
All trues, no falses. Need both sides of that.
There was a problem hiding this comment.
Ah, good point! I guess by default I am a "happy path" kind of a guy 😄 I will add some failing steps as well.
56b9fd2 to
8217f67
Compare
|
@ferventcoder I have fixed up with your comments, and re-pushed. However... :-( I started adding in the unhappy paths, as you suggested, and this highlighted an error in the logic. See the failing test. Any ideas on best approach to go forward? It all comes down to not knowing the valid TLD's in order to move forward. I really don't want to have to start pulling in a complete list of TLD's and comparing against them, as these lists are always changing. What are your thoughts? |
|
I'll need to pull in the PR to see the failing test. |
|
@ferventcoder did you have any suggestions about this one, or did you get pulled onto something else? |
|
I didn't see the failing test yet. Might be best to comment on the PR files where the failing test is. |
There was a problem hiding this comment.
Is this the failing test?
There was a problem hiding this comment.
Yes.
And it is due to this line:
I can change it to be > 3 but that then fails another test.
There was a problem hiding this comment.
Dumb idea Monday - most double TLDs are both two letters.
There was a problem hiding this comment.
I take it back. The last one is 2 letters. The other is either co or one of the well known ones like org, edu. We'd catch enough of the items, it's probably okay if a few false positives drop.
There was a problem hiding this comment.
I had that idea on Dumb Idea Saturday, but wasn't sure if it was going to be a winner or not. Happy to proceed on that basis though.
There was a problem hiding this comment.
I guess we can add some exemptions, as we see them start to come in.
|
Is this ready to go? |
|
@ferventcoder no, this still has a failing test :-( I keep coming back to this one, and not liking the solutions that I come up with :-( |
- To ensure that the IconUrl either comes from the same domain as the ProjectUrl, or comes from the RawGit CDN - Fixes chocolatey-archiveGH-14
- To cover the functionality of the get_domain_from_host method

ProjectUrl, or comes from the RawGit CDN