Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jan-carreras
Copy link
Contributor

@jan-carreras jan-carreras commented Aug 15, 2020

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #16

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Running existing tests
  • Created new tests

Increased the coverage to 100%

Checklist:

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have rebased my branch to include the latest changes from master

The middle dash character "-" was not the ASCII 0xD2 but some other representation: 0xE28093 preventing the correct comparison in the code logic and ignoring the record
The condition had the wrong operand. Improve test cases to ensure that the result is the one expected, not just the cardinality.

Increase coverage by testing a not found port
The results were inconsistent since References are not sorted by single-port first and wide port ranges may match before single port ones. This is not a breaking change since the logic of InRange being used in the app checks first for specific ports
Copy link
Contributor Author

@jan-carreras jan-carreras left a comment

Choose a reason for hiding this comment

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

(I've never tried this "review" thing, don't really know what I'm doing. I'm just trying to add more information to the PR so it's easy to verify)

},
{
Name: "15601590",
Name: "1560-1590",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the commit message:

The middle dash character "-" was not the ASCII 0xD2 but some other representation: 0xE28093 preventing the correct comparison in the code logic and ignoring the record

non-ascii-char

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test failing before doing the replacements of chars in files:

=== RUN   TestPortsConsistencyValidation
    httpref_test.go:96: Invalid port format: 71–74
    httpref_test.go:96: Invalid port format: 225–241
    httpref_test.go:96: Invalid port format: 249–255
    httpref_test.go:96: Invalid port format: 1011–1020
    httpref_test.go:96: Invalid port format: 1560–1590
    httpref_test.go:96: Invalid port format: 1582–1583
    httpref_test.go:96: Invalid port format: 2222–2226
    [... redacted... 48 offending rules in total]

Copy link
Owner

Choose a reason for hiding this comment

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

Aaaaand this is why the previous test was necessary. 😄

Copy link
Contributor Author

@jan-carreras jan-carreras left a comment

Choose a reason for hiding this comment

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

Decide if we want to delete the logic of InRange of single-port-detection

@dnnrly
Copy link
Owner

dnnrly commented Aug 15, 2020

Dont sweat the self review too much. That checkbox is there to make sure people have given their code a once over before the formally submit the PR.

For me, it's important that you made the right fix and the tests pass.

Do you think it's ready?

@jan-carreras
Copy link
Contributor Author

Hi @dnnrly , yes hi think it's ready.

It's my first contribution to an Open Source project and I'm doing the same I usually do at work — I'll be less verbose in future PRs 👍

@dnnrly
Copy link
Owner

dnnrly commented Aug 15, 2020

Wow, I am honoured that you chose this project to be your first contribution. It shows that you review code at work and it's very much appreciated.

As for this PR, I will resolve all of the comments you've made so don't think that I'm ignoring them. I am away from any computers this week so it may take a little while to take it all in.

{having: "19150", expect: "10000-20000"},
{having: "16406", expect: "10000-20000"},
{having: "5988", expect: "5988-5989"},
{having: "5989", expect: "5988-5989"},
Copy link
Owner

Choose a reason for hiding this comment

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

I like this change. It says what we're testing more succinctly.

assert.Equal(t, 5, len(n))
}

func TestPortsConsistencyValidation(t *testing.T) {
Copy link
Owner

Choose a reason for hiding this comment

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

I was going to ask if this test is necessary BUT I think it actually specifies the contract for naming port mappings. Well spotted!

@dnnrly dnnrly merged commit 62977bf into dnnrly:master Aug 15, 2020
@jan-carreras
Copy link
Contributor Author

Thanks for taking the time to review my comments, I really appreciate it. My first contribution 👏 👏 I'm so happy.

@jan-carreras jan-carreras deleted the #16-in-range-returns-incorrect-registered-port branch August 16, 2020 08:07
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.

InRange returns incorrect registered ports

2 participants