Hello nice people of Hugo.
I started to learn Hugo, in order to be able to contribute. In following the suggestion that tests should be added first, and because I think writing tests makes you understand the framework, I started to add tests to the Helpers package since coverage is pretty low there.
I’m using => go test -coverprofile=cover.out
and then go tool cover -html=cover.out
in order to detect where I can increase coverage and what tests are missing.
I added my first test example, though it’s not testing the actual configuration yet, it’s only testing if a set flag is truly set or not.
I will write again, once I finish getting it close to a 100%.
I’m looking forward to become an active contributor to Hugo, I love it very much, both of my sites is running with Hugo.
Here is the link to my first commit -> https://github.com/Skarlso/hugo/commit/c4e5357c36697aac2f40aecd411768ba361c46bf
I also run fmt and lint on content.go.
I appreciate any help, or suggestions as I go on about contributing or, the tests I’ll write!
Thank you!
Gergely.
3 Likes
Looks like a good start. I commented on your commit in Github.
1 Like
Thank you for the review! I know now that it is a good direction. I shall continue onward.
I would recommend that you always create a separate branch in your git repo for your changes. Here’s my normal workflow when working in my own git repo:
git checkout master
git pull
git checkout -b myfeature
# make changes...
git commit -a -v
git push --set-upstream origin myfeature
# now you're ready to make a PR
This normally requires using govers to rewrite import paths. You can avoid that by adding your fork as a git-remote in sp13/hugo.
1 Like
Sure, I usually do that. But this time… I just… did not. I have no excuses.
I shall add it presently. Thanks!
EDIT: Done. Change is now on a different branch. Thanks for reminding me.
GetHTMLRenderer has not a 100% coverage. Though if ANYBODY has a better way of covering this part ->
if b && !ctx.getConfig().PlainIDAnchors {
renderParameters.FootnoteAnchorPrefix = ctx.DocumentID + ":" + renderParameters.FootnoteAnchorPrefix
renderParameters.HeaderIDSuffix = ":" + ctx.DocumentID
}
I’ll be happy. Right now, I’m testing this with sort of reflection.
Link to the relevant commit -> https://github.com/Skarlso/hugo/commit/c2388d1700074dc5c3cc4bb41c1c815ab7725587
Turning the output into actual textual output since I couldn’t find anything in blackfriday which would help me out in rendering the renderer and seeing the parameters applied. I was able to do a partial check with blackfriday.Markdown but wasn’t working either.
So if anybody has a brighter idea here PLEASE share, so I can learn.
Thanks!
Found in content_test_renderer -> renderWithMmark
Will amend the test to use that. Nice. As I read, I knew there must have been something to test the renderer.
Finally dawned on me how to use the renderer. Now I can test it better while I’m using the renderer to test actual rendered content properly. Good stuff.
1 Like