Hugolib/helpers - first stab at extra tests

Hi Steve,

OK after a mad few weeks professionally, I’ve finally got back to
looking the the tests in hugo.

I think there is still a bug in GuessSection, but I want to clarify the
behaviour first.

I’ve pushed the code to my extend-hugolib-tests branch as normal and
this is what I am seeing:

The tests that fail are:

Test number value, expected result
9 {"/content/blog/", “blog”},
10 {"/content/blog", “blog”},
11 {“content/blog/”, “”},
12 {"/contents/myblog/", “contents”},
14 {"/contents/ourblog/", “contents”},

With:

— FAIL: TestGuessSection (0.00 seconds)
path_test.go:442: Test 9 failed. Expected “blog” got "content/blog"
path_test.go:442: Test 10 failed. Expected “blog” got "content"
path_test.go:442: Test 11 failed. Expected “” got “blog"
path_test.go:442: Test 12 failed. Expected “contents” got
"contents/myblog"
path_test.go:442: Test 14 failed. Expected “contents” got
"contents/ourblog”

Now, I know GuessSection correctly filters out “content” as the first
part of the path, so that the standard hugo content directory is
removed. But what is the intended behaviour when more then one
path/directory element is passed?

As I understood things, see your explanation below, the path has to
start with a “/” and a section is the first part of the path. With any
"content" chopped. And a section can’t have a “/” anywhere within it.
Which implies to me that the section is always the bit between the first
two “/”'s, after “content” has been removed.

Can you confirm if this is the correct understanding and I’ll update the
code and the tests to reflect this.

Thanks

Owen