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

Implement lab05 stringer for anz-bank go-course #526

Closed
wants to merge 4 commits into from

Conversation

undrewb
Copy link
Collaborator

@undrewb undrewb commented Jul 1, 2019

Fixes #525

Review of colleague's PR #511

Changes proposed in this PR:

  • Implement lab05 stringer for anz-bank go-course
  • Implement assertion based tests.

Update test to fix newline issue
@codecov
Copy link

codecov bot commented Jul 1, 2019

Codecov Report

Merging #526 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #526     +/-   ##
=======================================
  Coverage     100%   100%             
=======================================
  Files          73    187    +114     
  Lines        1273   3520   +2247     
=======================================
+ Hits         1273   3520   +2247
Impacted Files Coverage Δ
05_stringer/undrewb/main.go 100% <100%> (ø)
06_puppy/runnerdave/map_store.go 100% <0%> (ø)
10_rest/n0npax/cmd/puppy-server/main.go 100% <0%> (ø)
06_puppy/mohitnag/main.go 100% <0%> (ø)
10_rest/n0npax/pkg/puppy/errors.go 100% <0%> (ø)
06_puppy/kasunfdo/main.go 100% <0%> (ø)
07_errors/willshen8/error.go 100% <0%> (ø)
04_numeronym/davidbroughsmyth/main.go 100% <0%> (ø)
06_puppy/pfannerj/syncstore.go 100% <0%> (ø)
03_letters/alanhillgemann/main.go 100% <0%> (ø)
... and 105 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1fb10a5...96fbaf8. Read the comment docs.

@patrickmarabeas
Copy link
Collaborator

LGTM

As a side note - you can get rid of the \n in your TestMainOutput by using fmt.Fprint instead of fmt.Fprintln in main()

@anzdaddy
Copy link
Member

anzdaddy commented Jul 3, 2019

I advise against changing main just to make TestMainOutput slightly simpler. The use of Fprintln makes for cleaner output, e.g.:

user@machine:~$ lab05-fprintln
127.0.0.1
user@machine:~$ _
user@machine:~$ lab05-println
127.0.0.1user@machine:~$ _

05_stringer/undrewb/main_test.go Outdated Show resolved Hide resolved
05_stringer/undrewb/main_test.go Show resolved Hide resolved
05_stringer/undrewb/main_test.go Outdated Show resolved Hide resolved
main()

want := strconv.Quote("127.0.0.1\n")
got := strconv.Quote(buf.String())
Copy link
Member

Choose a reason for hiding this comment

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

Why strconv.Quote?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, this seems to be a common pattern among go-course PRs. Is it recommended somewhere to do it this way?

Copy link
Contributor

Choose a reason for hiding this comment

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

It saves you typing `""127.0.0.1\n"" - which is the output of main, which needs to be tested for coverage. that's all.

Copy link
Contributor

@juliaogris juliaogris left a comment

Choose a reason for hiding this comment

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

Pretty close.

05_stringer/undrewb/main_test.go Outdated Show resolved Hide resolved
05_stringer/undrewb/main_test.go Outdated Show resolved Hide resolved
05_stringer/undrewb/main_test.go Show resolved Hide resolved
05_stringer/undrewb/main_test.go Outdated Show resolved Hide resolved
Change assert parameter order to be expected then actual
Fix formatting of test case structs
Copy link
Member

@rokane rokane left a comment

Choose a reason for hiding this comment

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

Looking really good. I have just a real minor one about a single indentation case. If you can quickly fix that please ping me on slack, I should be able to verify and give this an approval afterwards.

input: IPAddr{68, 2, 44, 125},
want: "68.2.44.125",
},
{name: "three octet addr",
Copy link
Member

Choose a reason for hiding this comment

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

The indentation on this is inconsistent with the rest, can you please fix this so this line starts on the one below

want: "68.2.44.125",
},
{
name: "three octet addr",

Choose a reason for hiding this comment

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

File is not goimports-ed (from goimports)

Suggested change
name: "three octet addr",
name: "three octet addr",

@juliaogris
Copy link
Contributor

The go-course is now closed. Thank you very much for participating.

@juliaogris juliaogris closed this Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement lab05 stringer for anz-bank go-course
6 participants